Skip to content

Commit e3cd744

Browse files
committed
Vector, Set -with-meta should return coll if meta identical
elide another impl specific LITE_MODE test add missing transiet impls to Vector
1 parent e6a6073 commit e3cd744

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12330,7 +12330,10 @@ reduces them without incurring seq initialization"
1233012330
-1)))))
1233112331

1233212332
IWithMeta
12333-
(-with-meta [coll meta] (Vector. meta array __hash))
12333+
(-with-meta [coll new-meta]
12334+
(if (identical? new-meta meta)
12335+
coll
12336+
(Vector. new-meta array __hash)))
1233412337

1233512338
ICloneable
1233612339
(-clone [coll] (Vector. meta array __hash))
@@ -12465,6 +12468,19 @@ reduces them without incurring seq initialization"
1246512468
(-persistent! [coll]
1246612469
coll)
1246712470

12471+
ITransientAssociative
12472+
(-assoc! [tcoll key val]
12473+
(-assoc-n! tcoll key val))
12474+
12475+
ITransientVector
12476+
(-assoc-n! [tcoll key val]
12477+
(if (number? key)
12478+
(-assoc-n tcoll key val)
12479+
(throw (js/Error. "Vector's key for assoc! must be a number."))))
12480+
12481+
(-pop! [tcoll]
12482+
(-pop tcoll))
12483+
1246812484
IIterable
1246912485
(-iterator [coll]
1247012486
(VectorIterator. array 0))
@@ -12962,7 +12978,10 @@ reduces them without incurring seq initialization"
1296212978
#(f (-val %) (-key %))))))
1296312979

1296412980
IWithMeta
12965-
(-with-meta [coll meta] (Set. meta hash-map __hash))
12981+
(-with-meta [coll new-meta]
12982+
(if (identical? new-meta meta)
12983+
coll
12984+
(Set. new-meta hash-map __hash)))
1296612985

1296712986
IMeta
1296812987
(-meta [coll] meta)

src/test/cljs/cljs/collections_test.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,9 @@
10191019

10201020
(deftest test-cljs-2128
10211021
(testing "Subvec iteration"
1022-
(testing "Subvec over PersistentVector uses RangedIterator"
1023-
(is (instance? RangedIterator (-iterator (subvec [0 1 2 3] 1 3)))))
1022+
(when-not ^boolean LITE_MODE
1023+
(testing "Subvec over PersistentVector uses RangedIterator"
1024+
(is (instance? RangedIterator (-iterator (subvec [0 1 2 3] 1 3))))))
10241025
(testing "Subvec over other vectors uses naive SeqIter"
10251026
(is (instance? SeqIter (-iterator (subvec (->CustomVectorThing [0 1 2 3]) 1 3))))))
10261027
(testing "Subvec reduce"

0 commit comments

Comments
 (0)