Skip to content

Commit 6679e2b

Browse files
danskardadnolen
authored andcommitted
Use volatile! instead of atom in transducers
1 parent ff325af commit 6679e2b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/cljs/cljs/core.cljs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,12 +3529,12 @@ reduces them without incurring seq initialization"
35293529
provided."
35303530
([f]
35313531
(fn [rf]
3532-
(let [ia (atom -1)]
3532+
(let [ia (volatile! -1)]
35333533
(fn
35343534
([] (rf))
35353535
([result] (rf result))
35363536
([result input]
3537-
(let [i (swap! ia inc)
3537+
(let [i (vswap! ia inc)
35383538
v (f i input)]
35393539
(if (nil? v)
35403540
result
@@ -3689,13 +3689,13 @@ reduces them without incurring seq initialization"
36893689
no collection is provided."
36903690
([n]
36913691
(fn [rf]
3692-
(let [na (atom n)]
3692+
(let [na (volatile! n)]
36933693
(fn
36943694
([] (rf))
36953695
([result] (rf result))
36963696
([result input]
36973697
(let [n @na
3698-
nn (swap! na dec)
3698+
nn (vswap! na dec)
36993699
result (if (pos? n)
37003700
(rf result input)
37013701
result)]
@@ -3713,13 +3713,13 @@ reduces them without incurring seq initialization"
37133713
Returns a stateful transducer when no collection is provided."
37143714
([n]
37153715
(fn [rf]
3716-
(let [na (atom n)]
3716+
(let [na (volatile! n)]
37173717
(fn
37183718
([] (rf))
37193719
([result] (rf result))
37203720
([result input]
37213721
(let [n @na]
3722-
(swap! na dec)
3722+
(vswap! na dec)
37233723
(if (pos? n)
37243724
result
37253725
(rf result input))))))))
@@ -3751,7 +3751,7 @@ reduces them without incurring seq initialization"
37513751
stateful transducer when no collection is provided."
37523752
([pred]
37533753
(fn [rf]
3754-
(let [da (atom true)]
3754+
(let [da (volatile! true)]
37553755
(fn
37563756
([] (rf))
37573757
([result] (rf result))
@@ -3760,7 +3760,7 @@ reduces them without incurring seq initialization"
37603760
(if (and drop? (pred input))
37613761
result
37623762
(do
3763-
(reset! da nil)
3763+
(vreset! da nil)
37643764
(rf result input)))))))))
37653765
([pred coll]
37663766
(let [step (fn [pred coll]
@@ -7776,12 +7776,12 @@ reduces them without incurring seq initialization"
77767776
transducer when no collection is provided."
77777777
([n]
77787778
(fn [rf]
7779-
(let [ia (atom -1)]
7779+
(let [ia (volatile! -1)]
77807780
(fn
77817781
([] (rf))
77827782
([result] (rf result))
77837783
([result input]
7784-
(let [i (swap! ia inc)]
7784+
(let [i (vswap! ia inc)]
77857785
(if (zero? (rem i n))
77867786
(rf result input)
77877787
result)))))))
@@ -7802,7 +7802,7 @@ reduces them without incurring seq initialization"
78027802
([f]
78037803
(fn [rf]
78047804
(let [a (array-list)
7805-
pa (atom ::none)]
7805+
pa (volatile! ::none)]
78067806
(fn
78077807
([] (rf))
78087808
([result]
@@ -7816,7 +7816,7 @@ reduces them without incurring seq initialization"
78167816
([result input]
78177817
(let [pval @pa
78187818
val (f input)]
7819-
(reset! pa val)
7819+
(vreset! pa val)
78207820
(if (or (keyword-identical? pval ::none)
78217821
(= val pval))
78227822
(do
@@ -8436,13 +8436,13 @@ reduces them without incurring seq initialization"
84368436
Returns a transducer when no collection is provided."
84378437
([]
84388438
(fn [rf]
8439-
(let [pa (atom ::none)]
8439+
(let [pa (volatile! ::none)]
84408440
(fn
84418441
([] (rf))
84428442
([result] (rf result))
84438443
([result input]
84448444
(let [prior @pa]
8445-
(reset! pa input)
8445+
(vreset! pa input)
84468446
(if (= prior input)
84478447
result
84488448
(rf result input))))))))

0 commit comments

Comments
 (0)