Closed borkdude closed 1 year ago
When compiling (zero? ..) we can inline the implementation and skip the function call.
(zero? ..)
That should speed up this output:
$ node out/eval.js -e '(time (print (loop [i 0 j 10000000] (if (zero? j) i (recur (inc i) (dec j))))))' 10000000 "Elapsed time: 132.894250 msecs"
I think it becomes slower due to:
(cljs.core.truth_(cljs.core.zero_QMARK_.call(null, j2)))
CLJS compiles this directly into:
cljs.user=> (prn (str (fn [x] (if (zero? x) 1 2)))) "function (x){\nif((x === (0))){\nreturn (1);\n} else {\nreturn (2);\n}\n}"
So the truth_ check is omitted and also the zero? function call.
When compiling
(zero? ..)
we can inline the implementation and skip the function call.That should speed up this output:
I think it becomes slower due to:
CLJS compiles this directly into:
So the truth_ check is omitted and also the zero? function call.