Skip to content
Snippets Groups Projects
Commit c2c60f3b authored by Cam Saul's avatar Cam Saul
Browse files

use `(into {})` instead of `(reduce merge {})` or `(apply merge {})` --

it's a lot faster
parent 6eff3399
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@
table-id->name (->> (sel :many [Table :id :name] :db_id id) ; fetch all name + ID of all Tables for this DB
(map (fn [{:keys [id name]}] ; make a map of Table ID -> Table Name
{id name}))
(apply merge {}))
(into {}))
matching-tables (->> (vals table-id->name) ; get all Table names that start with PREFIX
(filter (fn [^String table-name]
(= prefix (.substring table-name 0 prefix-len))))
......
......@@ -35,7 +35,7 @@
:id [in field-ids]) ; Fetch names of fields from `fields` clause
(map (fn [{:keys [id name]}] ; build map of field-id -> field-name
{id (keyword name)}))
(reduce merge {}))]
(into {}))]
(map field-id->name field-ids))) ; now get names in same order as the IDs
other-fields (->> (first results)
keys ; Get the names of any other fields that were returned (i.e., `sum`)
......@@ -52,7 +52,7 @@
:table_id table-id :name [in (set column-names)])
(map (fn [{:keys [name] :as column}] ; build map of column-name -> column
{name (select-keys column [:id :table_id :name :description :base_type :special_type])}))
(apply merge {}))]
(into {}))]
(->> column-names
(map (fn [column-name]
(or (columns column-name) ; try to get matching column from the map we build earlier
......
......@@ -81,7 +81,7 @@
objs (->> (sel :many entity :id [in ids])
(map (fn [obj]
{(:id obj) obj}))
(reduce merge {}))]
(into {}))]
(->> results
(map (fn [result]
(let [source-id (result source-key)
......
......@@ -130,7 +130,7 @@
(reset! cached-setting-values (->> (sel :many Setting)
(map (fn [{k :key v :value}]
{(keyword k) v}))
(reduce merge {})))))
(into {})))))
(def ^:private cached-setting-values
(atom nil))
......
......@@ -146,5 +146,5 @@
{k (if (contains? auto-deserialize-dates-keys k)
(deserialize-date v)
(auto-deserialize-dates v))}))
(reduce merge {}))
(into {}))
:else response))
......@@ -23,7 +23,7 @@
(map (fn [[k v]]
{k (if (= v '$) `(~k ~source##)
v)}))
(reduce merge {}))]
(into {}))]
`(let [~source## ~source-obj]
~(clojure.walk/prewalk (partial $->prop source##)
dest-object))))
......
......@@ -167,7 +167,7 @@
(->> [:users :venues :checkins :categories]
(map (fn [table-kw]
{table-kw (f table-kw)}))
(reduce merge {})))
(into {})))
(def
^{:doc "A map of Table name keywords -> Table IDs.
......@@ -201,7 +201,7 @@
(integer? id)
(not (zero? id))]}
{(keyword (.toLowerCase name)) id}))
(reduce merge {}))))))
(into {}))))))
;; ## Users
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment