Skip to content

Commit

Permalink
check when chunked seq goes unchunked, #328
Browse files Browse the repository at this point in the history
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
stuarthalloway committed Apr 30, 2010
1 parent 08a9204 commit d2fce54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/clj/clojure/core/protocols.clj
Expand Up @@ -24,11 +24,13 @@
(internal-reduce
[s f val]
(if-let [s (seq s)]
(recur (chunk-next s)
f
(.reduce (chunk-first s) f val))
(if (chunked-seq? s)
(recur (chunk-next s)
f
(.reduce (chunk-first s) f val))
(internal-reduce s f val))
val))

clojure.lang.StringSeq
(internal-reduce
[str-seq f val]
Expand Down
3 changes: 3 additions & 0 deletions test/clojure/test_clojure/sequences.clj
Expand Up @@ -18,6 +18,9 @@
; apply, map, filter, remove
; and more...

(deftest test-reduce-from-chunked-into-unchunked
(= [1 2 \a \b] (into [] (concat [1 2] "ab"))))

(deftest test-reduce
(let [int+ (fn [a b] (+ (int a) (int b)))
arange (range 100) ;; enough to cross nodes
Expand Down

0 comments on commit d2fce54

Please sign in to comment.