Skip to content

Commit a5a9632

Browse files
EwenGswannodette
authored andcommitted
CLJS-1886: RangedIterator should only be created from cljs.core.PersistentVector instances
Create ranged iterators from APersistentVector instances only
1 parent 64f126f commit a5a9632

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5035,6 +5035,9 @@ reduces them without incurring seq initialization"
50355035
(declare tv-editable-root tv-editable-tail TransientVector deref
50365036
pr-sequential-writer pr-writer chunked-seq)
50375037

5038+
(defprotocol APersistentVector
5039+
"Marker protocol")
5040+
50385041
(deftype PersistentVector [meta cnt shift root tail ^:mutable __hash]
50395042
Object
50405043
(toString [coll]
@@ -5164,6 +5167,7 @@ reduces them without incurring seq initialization"
51645167
(-find [coll k]
51655168
[k (get coll k)])
51665169

5170+
APersistentVector
51675171
IVector
51685172
(-assoc-n [coll n val]
51695173
(cond
@@ -5485,7 +5489,9 @@ reduces them without incurring seq initialization"
54855489

54865490
IIterable
54875491
(-iterator [coll]
5488-
(ranged-iterator v start end)))
5492+
(if (implements? APersistentVector coll)
5493+
(ranged-iterator v start end)
5494+
(seq-iter coll))))
54895495

54905496
(es6-iterable Subvec)
54915497

0 commit comments

Comments
 (0)