Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
51 changes: 40 additions & 11 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?)))))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down