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

Have IndexedSeq implement IChunkedSeq

Description

In Clojure, small vectors support chunked-seq: For example (chunked-seq? (seq [1 2 3])).

In ClojureScript, this is currently not true because creating a ChunkedSeq instance is more expensive than simply creating an IndexedSeq instance for small vectors. See https://github.com/clojure/clojurescript/commit/e0fd7a07f959d6472a9b0c73b55be2627c40a0ec where IndexedSeq is created for vectors of size 31 or smaller.

But, if we consider making IndexedSeq itself implement IChunkedSeq we could regain perf for short vectors without making seq slower:

An experiment doing so exhibits these speedups under advanced

V8: 2.6, SpiderMonkey 2.4, JavaScriptCore 1.9, Nashorn 1.3, ChakraCore 2.2, GraalVM 2.8

for this case of a filter and map chain:

1 (simple-benchmark [xs [1 2 3 4 5 6 7 8 9 10 11 12 13 14]] (doall (filter even? (map inc xs))) 1e6)

Environment

None

Status

Assignee

David Nolen

Reporter

Mike Fikes

Labels

Approval

None

Patch

Code and Test

Priority

Major