Skip to content

Commit db62937

Browse files
committed
check for :lite-mode? - emit Vector if set
1 parent dba928b commit db62937

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12232,9 +12232,9 @@ reduces them without incurring seq initialization"
1223212232

1223312233
;;; Vector
1223412234

12235-
(deftype Vector [meta array]
12235+
(deftype Vector [meta array ^:mutable __hash]
1223612236
IWithMeta
12237-
(-with-meta [coll meta] (Vector. meta array))
12237+
(-with-meta [coll meta] (Vector. meta array __hash))
1223812238

1223912239
IMeta
1224012240
(-meta [coll] meta)
@@ -12248,14 +12248,14 @@ reduces them without incurring seq initialization"
1224812248
(if (> (.-length array) 0)
1224912249
(let [new-array (aclone array)]
1225012250
(. new-array (pop))
12251-
(Vector. meta new-array))
12251+
(Vector. meta new-array nil))
1225212252
(throw (js/Error. "Can't pop empty vector"))))
1225312253

1225412254
ICollection
1225512255
(-conj [coll o]
1225612256
(let [new-array (aclone array)]
1225712257
(.push new-array o)
12258-
(Vector. meta new-array)))
12258+
(Vector. meta new-array nil)))
1225912259

1226012260
IEmptyableCollection
1226112261
(-empty [coll] (with-meta (. Vector -EMPTY) meta))
@@ -12298,7 +12298,7 @@ reduces them without incurring seq initialization"
1229812298
(-assoc [coll k v]
1229912299
(let [new-array (aclone array)]
1230012300
(aset new-array k v)
12301-
(Vector. meta new-array)))
12301+
(Vector. meta new-array nil)))
1230212302

1230312303
IVector
1230412304
(-assoc-n [coll n val] (-assoc coll n val))
@@ -12318,9 +12318,9 @@ reduces them without incurring seq initialization"
1231812318
IPrintWithWriter
1231912319
(-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
1232012320

12321-
(set! (. Vector -EMPTY) (Vector. nil (array)))
12321+
(set! (. Vector -EMPTY) (Vector. nil (array) nil))
1232212322

12323-
(set! (. Vector -fromArray) (fn [xs] (Vector. nil xs)))
12323+
(set! (. Vector -fromArray) (fn [xs] (Vector. nil xs nil)))
1232412324

1232512325
; The keys field is an array of all keys of this map, in no particular
1232612326
; order. Any string, keyword, or symbol key is used as a property name

src/main/clojure/cljs/closure.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
:watch :watch-error-fn :watch-fn :install-deps :process-shim :rename-prefix :rename-prefix-namespace
212212
:closure-variable-map-in :closure-property-map-in :closure-variable-map-out :closure-property-map-out
213213
:stable-names :ignore-js-module-exts :opts-cache :aot-cache :elide-strict :fingerprint :spec-skip-macros
214-
:nodejs-rt :target-fn :deps-cmd :bundle-cmd :global-goog-object&array :node-modules-dirs})
214+
:nodejs-rt :target-fn :deps-cmd :bundle-cmd :global-goog-object&array :node-modules-dirs :lite-mode?})
215215

216216
(def string->charset
217217
{"iso-8859-1" StandardCharsets/ISO_8859_1

src/main/clojure/cljs/compiler.cljc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@
522522
(and (every? #(= (:op %) :const) keys)
523523
(= (count (into #{} keys)) (count keys)))))
524524

525+
(defn lite-mode? []
526+
(get-in @env/*compiler* [:options :lite-mode?]))
527+
525528
(defn emit-map [keys vals comma-sep distinct-keys?]
526529
(cond
527530
(zero? (count keys))
@@ -562,10 +565,17 @@
562565
", 5, cljs.core.PersistentVector.EMPTY_NODE, [" (comma-sep items) "], null)")
563566
(emits "cljs.core.PersistentVector.fromArray([" (comma-sep items) "], true)")))))
564567

568+
(defn emit-lite-vector [items comma-sep]
569+
(if (empty? items)
570+
(emits "cljs.core.Vector.EMPTY")
571+
(emits "new cljs.core.Vector(null, [" (comma-sep items) "], null)")))
572+
565573
(defmethod emit* :vector
566574
[{:keys [items env]}]
567575
(emit-wrap env
568-
(emit-vector items comma-sep)))
576+
(if (lite-mode?)
577+
(emit-lite-vector items comma-sep)
578+
(emit-vector items comma-sep))))
569579

570580
(defn distinct-constants? [items]
571581
(let [items (map ana/unwrap-quote items)]

0 commit comments

Comments
 (0)