Navigation Menu

Skip to content

Commit

Permalink
CLJS-492: avoid producing unnecessary calls to next in emit-apply-to
Browse files Browse the repository at this point in the history
Includes two new entries in benchmark_runner.cljs.
  • Loading branch information
michalmarczyk authored and swannodette committed Apr 4, 2013
1 parent 3ca249a commit 1a094e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions benchmark/cljs/benchmark_runner.cljs
Expand Up @@ -92,6 +92,8 @@
(simple-benchmark [xs (array-seq (array 1 2 3 4 5))] (apply list xs) 1000000)
(simple-benchmark [xs (list 1 2 3 4 5)] (apply list xs) 1000000)
(simple-benchmark [xs [1 2 3 4 5]] (apply list xs) 1000000)
(simple-benchmark [f (fn [a b & more])] (apply f (range 32)) 1000000)
(simple-benchmark [f (fn [a b c d e f g h i j & more])] (apply f (range 32)) 1000000)
(println)

(println ";; update-in")
Expand Down
19 changes: 6 additions & 13 deletions src/clj/cljs/compiler.clj
Expand Up @@ -382,24 +382,17 @@
delegate-name (str (munge name) "__delegate")
params (map munge params)]
(emitln "(function (" arglist "){")
(doseq [[i param] (map-indexed vector (butlast params))]
(doseq [[i param] (map-indexed vector (drop-last 2 params))]
(emits "var " param " = cljs.core.first(")
(dotimes [_ i] (emits "cljs.core.next("))
(emits arglist ")")
(dotimes [_ i] (emits ")"))
(emitln ";"))
(emitln arglist ");")
(emitln arglist " = cljs.core.next(" arglist ");"))
(if (< 1 (count params))
(do
(emits "var " (last params) " = cljs.core.rest(")
(dotimes [_ (- (count params) 2)] (emits "cljs.core.next("))
(emits arglist)
(dotimes [_ (- (count params) 2)] (emits ")"))
(emitln ");")
(emitln "var " (last (butlast params)) " = cljs.core.first(" arglist ");")
(emitln "var " (last params) " = cljs.core.rest(" arglist ");")
(emitln "return " delegate-name "(" (string/join ", " params) ");"))
(do
(emits "var " (last params) " = ")
(emits "cljs.core.seq(" arglist ");")
(emitln ";")
(emitln "var " (last params) " = cljs.core.seq(" arglist ");")
(emitln "return " delegate-name "(" (string/join ", " params) ");")))
(emits "})")))

Expand Down

0 comments on commit 1a094e4

Please sign in to comment.