Skip to content

Commit

Permalink
* benchmark/cljs/benchmark_runner.cljs: CLJS-244: Brian Taylor's list…
Browse files Browse the repository at this point in the history
… create optimization
  • Loading branch information
David Nolen authored and David Nolen committed May 28, 2012
1 parent 9442643 commit b469952
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion benchmark/cljs/benchmark_runner.cljs
Expand Up @@ -19,7 +19,8 @@
(simple-benchmark [coll (list 1 2 3)] (-first coll) 1000000)
(simple-benchmark [coll (list 1 2 3)] (rest coll) 1000000)
(simple-benchmark [coll (list 1 2 3)] (-rest coll) 1000000)
(simple-benchmark [coll (list 1 2 3)] (next coll) 1000000)
(simple-benchmark [] (list) 1000000)
(simple-benchmark [] (list 1 2 3) 1000000)
(println)

(println ";;; vector ops")
Expand Down
10 changes: 8 additions & 2 deletions src/cljs/cljs/core.cljs
Expand Up @@ -1547,8 +1547,14 @@ reduces them without incurring seq initialization"
(rseq coll)
(reduce conj () coll)))

(defn list [& items]
(reduce conj () (reverse items)))
(defn list
([] ())
([x] (conj () x))
([x y] (conj (list y) x))
([x y z] (conj (list y z) x))
([x y z & items]
(conj (conj (conj (reduce conj () (reverse items))
z) y) x)))

(deftype Cons [meta first rest ^:mutable __hash]
IList
Expand Down

0 comments on commit b469952

Please sign in to comment.