Last active
November 9, 2016 18:16
-
-
Save darwin/34b2eaf97f1823b1180eb14ad64af9fd to your computer and use it in GitHub Desktop.
nothing from this namespace is used anywhere, so `:advanced` build should elide everything (our goal)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [m1 m2] | |
(loop [m m1 | |
ks (keys m2)] | |
(if (empty? ks) | |
m | |
(recur (assoc m (first ks) (get m2 (first ks))) (rest ks))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge (simple-merge default-config external-config) env-config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [m1 m2] | |
(loop [m m1 | |
ks (keys m2)] | |
(if (empty? ks) | |
m | |
(recur (assoc m (first ks) (get m2 (first ks))) (rest ks))))) | |
(defn simple-merge2 [m1 m2] | |
(loop [m m1 | |
ks (keys m2)] | |
(if (empty? ks) | |
m | |
(recur (assoc m (first ks) (get m2 (first ks))) (rest ks))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge2 (simple-merge default-config external-config) env-config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [m1 m2] | |
(loop [m m1 | |
ks (keys m2)] | |
(if (empty? ks) | |
m | |
(recur (assoc m (first ks) (get m2 (first ks))) (rest ks))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (array (simple-merge default-config external-config) (simple-merge default-config env-config))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [base-map & maps] | |
(let [rmaps (reverse maps) | |
extra-keys (dedupe (apply concat (map keys rmaps)))] | |
(loop [result base-map | |
ks extra-keys] | |
(if (empty? ks) | |
result | |
(let [key (first ks) | |
val (first (remove #{::not-found} (map #(get % key ::not-found) rmaps)))] | |
(recur (assoc result key val) (rest ks))))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge default-config external-config env-config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [base-map & maps] | |
(let [rmaps (reverse maps) | |
extra-keys (dedupe (apply concat (map keys rmaps)))] | |
(loop [result base-map | |
ks extra-keys] | |
(if (empty? ks) | |
result | |
(let [key (first ks) | |
val (first (mapcat #(let [v (get % key :not-found)] | |
(if-not (= v :not-found) | |
[v])) rmaps))] | |
(recur (assoc result key val) (rest ks))))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge default-config external-config env-config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies on protocol checks and this is too dymamic to be elided | |
(defn simple-merge [base-map & maps] | |
(let [rmaps (reverse maps) | |
extra-keys (dedupe (apply concat (map keys rmaps)))] | |
(loop [result base-map | |
ks extra-keys] | |
(if (empty? ks) | |
result | |
(let [key (first ks) | |
val (first (remove #{:not-found} (map #(get % key :not-found) rmaps)))] | |
(recur (assoc result key val) (rest ks))))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge default-config external-config env-config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; we cannot use cljs.core/merge because that would confuse advanced mode compilation | |
; if you look at cljs.core/merge you will see that it relies reduce which relieas on protocol checks and | |
; this is probably too dymamic to be elided (my theory) | |
(defn simple-merge [base-map & maps] | |
(let [rmaps (reverse maps) | |
sentinel (js-obj) | |
sentinel? #{sentinel} | |
merged-keys (dedupe (sort (apply concat (map keys rmaps))))] | |
(loop [result base-map | |
todo-keys merged-keys] | |
(if (empty? todo-keys) | |
result | |
(let [key (first todo-keys) | |
val (first (remove sentinel? (map #(get % key sentinel) rmaps)))] | |
(recur (assoc result key val) (rest todo-keys))))))) | |
(def default-config defaults/prefs) | |
(def external-config (emit-external-config)) | |
(def env-config (emit-env-config)) | |
(def initial-config (simple-merge default-config external-config env-config)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tested with ClojureScript 1.9.293