Skip to content

Commit c47e1bb

Browse files
puredangerstuarthalloway
authored andcommitted
CLJ-1669 - replace LazyTransformer with TransformerIterator. eduction takes multiple xforms. iterator-seq is now chunked.
Signed-off-by: Stuart Halloway <[email protected]>
1 parent fab940d commit c47e1bb

File tree

5 files changed

+305
-389
lines changed

5 files changed

+305
-389
lines changed

src/clj/clojure/core.clj

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,9 +2526,15 @@
25262526
(if (seq? coll) coll
25272527
(or (seq coll) ())))
25282528
([xform coll]
2529-
(clojure.lang.LazyTransformer/create xform coll))
2529+
(or (clojure.lang.RT/chunkIteratorSeq
2530+
(clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll)))
2531+
()))
25302532
([xform coll & colls]
2531-
(clojure.lang.LazyTransformer/createMulti xform (to-array (cons coll colls)))))
2533+
(or (clojure.lang.RT/chunkIteratorSeq
2534+
(clojure.lang.TransformerIterator/createMulti
2535+
xform
2536+
(map #(clojure.lang.RT/iter %) (cons coll colls))))
2537+
())))
25322538

25332539
(defn every?
25342540
"Returns true if (pred x) is logical true for every x in coll, else
@@ -5473,7 +5479,7 @@
54735479
{:added "1.0"
54745480
:static true}
54755481
[iter]
5476-
(clojure.lang.IteratorSeq/create iter))
5482+
(clojure.lang.RT/chunkIteratorSeq iter))
54775483

54785484
(defn enumeration-seq
54795485
"Returns a seq on a java.util.Enumeration"
@@ -7320,10 +7326,8 @@
73207326

73217327
(deftype Eduction [xform coll]
73227328
Iterable
7323-
(iterator [_] (.iterator ^java.util.Collection (sequence xform coll)))
7324-
7325-
clojure.lang.Seqable
7326-
(seq [_] (seq (sequence xform coll)))
7329+
(iterator [_]
7330+
(clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll)))
73277331

73287332
clojure.lang.IReduceInit
73297333
(reduce [_ f init]
@@ -7333,12 +7337,14 @@
73337337
clojure.lang.Sequential)
73347338

73357339
(defn eduction
7336-
"Returns a reducible/iterable/seqable application of
7337-
the transducer to the items in coll. Note that these applications
7338-
will be performed every time reduce/iterator/seq is called."
7339-
{:added "1.7"}
7340-
[xform coll]
7341-
(Eduction. xform coll))
7340+
"Returns a reducible/iterable application of the transducers
7341+
to the items in coll. Transducers are applied in order as if
7342+
combined with comp. Note that these applications will be
7343+
performed every time reduce/iterator is called."
7344+
{:arglists '([xform* coll])
7345+
:added "1.7"}
7346+
[& xforms]
7347+
(Eduction. (apply comp (butlast xforms)) (last xforms)))
73427348

73437349
(defmethod print-method Eduction [c, ^Writer w]
73447350
(if *print-readably*

0 commit comments

Comments
 (0)