Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove unnecessary `Hash#to_a` call

Inspired by 931ee41

```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
```
  • Loading branch information...
commit ee92c61689dd2cd0700d136385a3d2616c993e10 1 parent 66dd216
Viktar Basharymau DNNX authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  actionpack/lib/action_dispatch/journey/formatter.rb
2  actionpack/lib/action_dispatch/journey/formatter.rb
View
@@ -80,7 +80,7 @@ def match_route(name, options)
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) }
Please sign in to comment.
Something went wrong with that request. Please try again.