[CLJ-740] Unnecessary boxing of primitives in case form Created: 17/Feb/11 Updated: 01/Mar/11
|Affects Version/s:||Release 1.3|
Found this while profiling some performance-critical code.
Consider the following Clojure function:
Current Clojure 1.3 snapshot compiles it to:
This bytecode contains boxing of primitives (calls to clojure/lang/Numbers.num and java/lang/Double.valueOf) and calls to clojure/lang/Util.hash and clojure/lang/Util.equals that does not seem necessary.
At 60-66 primitive double is boxed into Double only to be converted back into primitive.
The equivalent Java code compiles to much simpler and faster bytecode:
|Comment by Alexander Taggart [ 28/Feb/11 2:16 PM ]|
Improved via patch on
now emits as
or if the int cast of the expression is omitted: