diff --git a/benchmark/cljs/benchmark_runner.cljs b/benchmark/cljs/benchmark_runner.cljs index da1a4e5df2..d0d48d6548 100644 --- a/benchmark/cljs/benchmark_runner.cljs +++ b/benchmark/cljs/benchmark_runner.cljs @@ -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") diff --git a/src/cljs/cljs/core.cljs b/src/cljs/cljs/core.cljs index 8484bf7337..c4f8e28e8a 100644 --- a/src/cljs/cljs/core.cljs +++ b/src/cljs/cljs/core.cljs @@ -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