diff options
author | Viktar Basharymau <viktar.basharymau@thehamon.com> | 2014-05-22 21:16:56 +0300 |
---|---|---|
committer | Viktar Basharymau <viktar.basharymau@thehamon.com> | 2014-05-22 21:16:56 +0300 |
commit | ee92c61689dd2cd0700d136385a3d2616c993e10 (patch) | |
tree | 5c84e26a806d9190848ee52c2dc634ba39cd8375 /actionpack/lib/action_dispatch | |
parent | 66dd216705c9401cfa559a52910df80bd9c7808b (diff) | |
download | rails-ee92c61689dd2cd0700d136385a3d2616c993e10.tar.gz rails-ee92c61689dd2cd0700d136385a3d2616c993e10.tar.bz2 rails-ee92c61689dd2cd0700d136385a3d2616c993e10.zip |
Remove unnecessary `Hash#to_a` call
Inspired by https://github.com/rails/rails/commit/931ee4186b877856b212b0085cd7bd7f6a4aea67
```ruby
def stat(num)
start = GC.stat(:total_allocated_object)
num.times { yield }
total_obj_count = GC.stat(:total_allocated_object) - start
puts "#{total_obj_count / num} allocations per call"
end
h = { 'x' => 'y' }
stat(100) { h. each { |pair| pair } }
stat(100) { h.to_a.each { |pair| pair } }
__END__
1 allocations per call
2 allocations per call
```
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/formatter.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index 7eaf8e49ce..f76f0332d7 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -80,7 +80,7 @@ module ActionDispatch if named_routes.key?(name) yield named_routes[name] else - routes = non_recursive(cache, options.to_a) + routes = non_recursive(cache, options) hash = routes.group_by { |_, r| r.score(options) } |