Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.2
-
Component/s: Compiler, Interpreter
-
Labels:None
-
Number of attachments :
Description
Currently, multiple assignment returns an array of the RHS:
~/NetBeansProjects/jruby ➔ ruby -e "p((a, b, c = 1, 2, 3))" [1, 2, 3]
If this new array is not used, it is wasted. So a simple optimization for this would be to only have the result of masgn produce an array iff there's a consumer for that result.
We should make this optimization in both the interpreter and compiler. Might be a good one for an interpreter or compiler newb to try out.
Fixed this in 1.2, and boy what a fix. Uniform masgn up to 10 arguments is many times faster now when the array is not used. The compiler tracks whether a piece of code is being used as an expression, and follows the array-constructing path only in that case.