JRuby

Multiple assignment could be made faster by not returning unused array

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.2
  • Component/s: Compiler, Interpreter
  • Labels:
    None
  • Number of attachments :
    0

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.

Activity

Hide
Charles Oliver Nutter added a comment -

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.

Show
Charles Oliver Nutter added a comment - 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.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: