Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove splats #260

Merged
merged 1 commit into from
Apr 6, 2015
Merged

remove splats #260

merged 1 commit into from
Apr 6, 2015

Conversation

ASnow
Copy link
Contributor

@ASnow ASnow commented Apr 3, 2015

Removed +arguments+ splat operator in private method +#_extract_hash_values+
Removed +arguments+ splat operator in private method +#_extract_method_values+

@rwz
Copy link
Collaborator

rwz commented Apr 3, 2015

What's the purpose of this change?

@rwz rwz closed this Apr 6, 2015
@ASnow
Copy link
Contributor Author

ASnow commented Apr 6, 2015

Performance optimization

require 'benchmark'

class MethodWithSplat
  def method1 a1, *args
    method2 a1, *args
  end
  private
  def method2 a1, *args
  end
end
class MethodWithoutSplat
  def method1 a1, *args
    method2 a1, args
  end
  private
  def method2 a1, args
  end
end


a = MethodWithSplat.new
b = MethodWithoutSplat.new

called = 10_000_000
Benchmark.benchmark do |x|
  x.report("with splat:")   { called.times{ a.method1 nil, nil, nil } }
  x.report("without splat:")   { called.times{ b.method1 nil, nil, nil } }
end

#with splat:  6.030000   0.000000   6.030000 (  4.133987)
#without splat:  0.000000   0.000000   0.000000 (  2.446851)

@rwz rwz reopened this Apr 6, 2015
rwz added a commit that referenced this pull request Apr 6, 2015
Remove splats for performance reasons
@rwz rwz merged commit 116fbb6 into rails:master Apr 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants