Skip to content

Commit 70c4abf

Browse files
thomasmulvaneymfikes
authored andcommitted
CLJS-3000: Don't pass meta to next/rest/empty of seqs
* Fix metadata on ChunkedCons, ValSeq and PersistentTreeMapSeq. * Remove multiples useless calls to with-meta when constructing EmptyLists introduced in CLJS-1888
1 parent 23ab9a0 commit 70c4abf

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/main/cljs/cljs/core.cljs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3590,15 +3590,15 @@ reduces them without incurring seq initialization"
35903590
(-first [coll] (-nth chunk 0))
35913591
(-rest [coll]
35923592
(if (> (-count chunk) 1)
3593-
(ChunkedCons. (-drop-first chunk) more meta nil)
3593+
(ChunkedCons. (-drop-first chunk) more nil nil)
35943594
(if (nil? more)
35953595
()
35963596
more)))
35973597

35983598
INext
35993599
(-next [coll]
36003600
(if (> (-count chunk) 1)
3601-
(ChunkedCons. (-drop-first chunk) more meta nil)
3601+
(ChunkedCons. (-drop-first chunk) more nil nil)
36023602
(when-not (nil? more)
36033603
(-seq more))))
36043604

@@ -3620,7 +3620,7 @@ reduces them without incurring seq initialization"
36203620
(cons o this))
36213621

36223622
IEmptyableCollection
3623-
(-empty [coll] (-with-meta (.-EMPTY List) meta))
3623+
(-empty [coll] (.-EMPTY List))
36243624

36253625
IHash
36263626
(-hash [coll] (caching-hash coll hash-ordered-coll __hash)))
@@ -8210,7 +8210,7 @@ reduces them without incurring seq initialization"
82108210
(-conj [coll o] (cons o coll))
82118211

82128212
IEmptyableCollection
8213-
(-empty [coll] (-with-meta (.-EMPTY List) meta))
8213+
(-empty [coll] (.-EMPTY List))
82148214

82158215
IHash
82168216
(-hash [coll] (caching-hash coll hash-ordered-coll __hash))
@@ -9051,7 +9051,7 @@ reduces them without incurring seq initialization"
90519051
(cons o coll))
90529052

90539053
IEmptyableCollection
9054-
(-empty [coll] (-with-meta (.-EMPTY List) _meta))
9054+
(-empty [coll] (.-EMPTY List))
90559055

90569056
IHash
90579057
(-hash [coll] (hash-ordered-coll coll))
@@ -9066,7 +9066,7 @@ reduces them without incurring seq initialization"
90669066
(-next mseq)
90679067
(next mseq))]
90689068
(if-not (nil? nseq)
9069-
(ValSeq. nseq _meta)
9069+
(ValSeq. nseq nil)
90709070
())))
90719071

90729072
INext
@@ -9075,7 +9075,7 @@ reduces them without incurring seq initialization"
90759075
(-next mseq)
90769076
(next mseq))]
90779077
(when-not (nil? nseq)
9078-
(ValSeq. nseq _meta))))
9078+
(ValSeq. nseq nil))))
90799079

90809080
IReduce
90819081
(-reduce [coll f] (seq-reduce f coll))
@@ -9746,7 +9746,7 @@ reduces them without incurring seq initialization"
97469746
(-conj [rng o] (cons o rng))
97479747

97489748
IEmptyableCollection
9749-
(-empty [rng] (-with-meta (.-EMPTY List) nil))
9749+
(-empty [rng] (.-EMPTY List))
97509750

97519751
ISequential
97529752
IEquiv

src/test/cljs/cljs/metadata_test.cljc

+18-3
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,24 @@
129129
(testing "Medium"
130130
(seq-interface-tests (seq (hash-map 0 1 2 3 4 5))))
131131
(testing "Large"
132-
(seq-interface-tests (seq (apply hash-map (range 100))))))
132+
(seq-interface-tests (seq (apply hash-map (range 100)))))
133+
(testing "KeySeq"
134+
(seq-interface-tests (keys (apply hash-map (range 10)))))
135+
(testing "ValSeq"
136+
(seq-interface-tests (vals (apply hash-map (range 10))))))
133137

134138
(testing "PersistentArrayMap"
135139
(testing "Empty"
136140
(seq-interface-tests (seq (array-map))))
137141
(testing "Medium"
138-
(seq-interface-tests (seq (array-map 0 1 2 3 4 5))))))
142+
(seq-interface-tests (seq (array-map 0 1 2 3 4 5))))
143+
(testing "KeySeq"
144+
(seq-interface-tests (keys (apply array-map (range 10)))))
145+
(testing "ValSeq"
146+
(seq-interface-tests (vals (apply array-map (range 10))))))
147+
148+
(testing "PersistentTreeMap"
149+
(seq-interface-tests (seq (sorted-map :a 1 :b 2 :c 3)))))
139150

140151
(testing "generators"
141152
(testing "cycle"
@@ -145,4 +156,8 @@
145156
(testing "repeat"
146157
(seq-interface-tests (repeat 10 :x)))
147158
(testing "iterate"
148-
(seq-interface-tests (iterate inc 0)))))
159+
(seq-interface-tests (iterate inc 0))))
160+
161+
(testing "ChunkedCons"
162+
(let [chunked-cons (seq (map inc (vec (range 100))))]
163+
(seq-interface-tests chunked-cons))))

0 commit comments

Comments
 (0)