diff --git a/deps.edn b/deps.edn index e3a236c2a..5233627bc 100644 --- a/deps.edn +++ b/deps.edn @@ -9,7 +9,11 @@ org.clojure/tools.reader {:mvn/version "1.3.6"} org.clojure/test.check {:mvn/version "1.1.1"}} :aliases - {:cli.test.run {:extra-paths ["src/test/cljs_cli"] + {:cljs-repl {:extra-paths ["src/test/cljs"] + :main-opts ["-m" "cljs.main" "-re" "node" "-d" ".cljs_repl" "-r"]} + :cljs-lite-repl {:extra-paths ["src/test/cljs"] + :main-opts ["-m" "cljs.main" "-co" "{:lite-mode true}" "-re" "node" "-d" ".cljs_lite_repl" "-r"]} + :cli.test.run {:extra-paths ["src/test/cljs_cli"] :main-opts ["-i" "src/test/cljs_cli/cljs_cli/test_runner.clj" "-e" "(cljs-cli.test-runner/-main)"]} :compiler.test {:extra-paths ["src/test/cljs" "src/test/cljs_build" "src/test/cljs_cp" diff --git a/src/main/cljs/cljs/core.cljs b/src/main/cljs/cljs/core.cljs index 82bd82c6b..707a7f0cd 100644 --- a/src/main/cljs/cljs/core.cljs +++ b/src/main/cljs/cljs/core.cljs @@ -4124,16 +4124,26 @@ reduces them without incurring seq initialization" (set! *unchecked-if* false) +(declare ObjMap) + ;; CLJS-3200: used by destructure macro for maps to reduce amount of repeated code ;; placed here because it needs apply and hash-map (only declared at this point) (defn --destructure-map [gmap] - (if (implements? ISeq gmap) - (if (next gmap) - (.createAsIfByAssoc PersistentArrayMap (to-array gmap)) - (if (seq gmap) - (first gmap) - (.-EMPTY PersistentArrayMap))) - gmap)) + (if ^boolean LITE_MODE + (if (implements? ISeq gmap) + (if (next gmap) + (.createAsIfByAssoc ObjMap (to-array gmap)) + (if (seq gmap) + (first gmap) + (.-EMPTY ObjMap))) + gmap) + (if (implements? ISeq gmap) + (if (next gmap) + (.createAsIfByAssoc PersistentArrayMap (to-array gmap)) + (if (seq gmap) + (first gmap) + (.-EMPTY PersistentArrayMap))) + gmap))) (defn vary-meta "Returns an object of the same type and value as obj, with @@ -7126,7 +7136,7 @@ reduces them without incurring seq initialization" (fn [init] ;; check trailing element (let [len (alength init) - has-trailing? (== 1 (bit-and len 1))] + has-trailing? (== 1 (bit-and len 1))] (if-not (or has-trailing? (pam-dupes? init)) (PersistentArrayMap. nil (/ len 2) init nil) (.createAsIfByAssocComplexPath PersistentArrayMap init has-trailing?))))) @@ -9039,9 +9049,13 @@ reduces them without incurring seq initialization" "Builds a map from a seq as described in https://clojure.org/reference/special_forms#keyword-arguments" [s] - (if (next s) - (.createAsIfByAssoc PersistentArrayMap (to-array s)) - (if (seq s) (first s) (.-EMPTY PersistentArrayMap)))) + (if ^boolean LITE_MODE + (if (next s) + (.createAsIfByAssoc ObjMap (to-array s)) + (if (seq s) (first s) (.-EMPTY ObjMap))) + (if (next s) + (.createAsIfByAssoc PersistentArrayMap (to-array s)) + (if (seq s) (first s) (.-EMPTY PersistentArrayMap))))) (defn sorted-map "keyval => key val @@ -12731,6 +12745,21 @@ reduces them without incurring seq initialization" (recur (nnext kvs))) (.fromObject ObjMap ks obj))))) +(set! (. ObjMap -createAsIfByAssoc) + (fn [init] + ;; check trailing element + (let [len (alength init) + has-trailing? (== 1 (bit-and len 1)) + init (if has-trailing? + (pam-grow-seed-array init + (into {} (aget init (dec len)))) + init) + len (alength init)] + (loop [i 0 ret {}] + (if (< i len) + (recur (+ i 2) (assoc ret (aget init i) (aget init (inc i)))) + ret))))) + (defn- scan-array-equiv [incr k array] (let [len (alength array)] (loop [i 0]