Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 61fbc4d3ead0
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 802b5071c6d9
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Sep 5, 2015

  1. Optimize splat args

    Turns out Array.prototype.slice(arguments, n) is slow because it can't
    be optimized in the VM, presumably because arguments is not an array so
    the Array prototype function balks at it. Iterating over arguments and
    copying them can be optimized, so it ends up being a lot faster.
    jgaskins committed Sep 5, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7d4002f View commit details
  2. Merge pull request #1096 from jgaskins/optimize-splat-args

    More splat args optimization
    meh committed Sep 5, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    802b507 View commit details
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/opal/nodes/def.rb
7 changes: 6 additions & 1 deletion lib/opal/nodes/def.rb
Original file line number Diff line number Diff line change
@@ -135,7 +135,12 @@ def compile_block_arg
def compile_rest_arg
if rest_arg and rest_arg[1]
splat = variable(rest_arg[1].to_sym)
line "var #{splat} = $slice.call(arguments, #{argc});"
line "var array_size = arguments.length - #{argc};"
line "if(array_size < 0) array_size = 0;"
line "var #{splat} = new Array(array_size);"
line "for(var arg_index = 0; arg_index < array_size; arg_index++) {"
line " #{splat}[arg_index] = arguments[arg_index + #{argc}];"
line "}"
end
end