We're updating the issue view to help you get more done. 

Small PVs are never chunked

Description

A PersistenVector that has <=32 elements and is seq'ed will return an IndexedSeq. Though IndexedSeq always fails the chunked-seq? check.

This means a:

1 2 (def xv (vec (range 32))) (reduce + (map inc xv))

is about 4x slower than a map over a vector with 33 elements.

Options:
1. Return a ChunkedCons with the "rest" set to nil in PersistentVector.seq()
2. Implement IChunkedSeq for IndexedSeq:

1 2 3 4 5 6 7 8 9 10 11 (extend-type IndexedSeq IChunkedSeq (-chunked-first [x] x) (-chunked-rest [x] ()) IChunkedNext (-chunked-next [x] nil) IChunk (-drop-first [coll] (if-some [n (-next coll)] n (throw (js/Error. "-drop-first of empty chunk")))))

I think option #2 is better since IndexedSeq is used quite a bunch throughout the code base, so the chunking will also kick in for many other code paths.

Environment

None

Status

Assignee

David Nolen

Reporter

Andre R

Labels

Approval

None

Patch

Code

Affects versions

1.9.908

Priority

Minor