From ee92c61689dd2cd0700d136385a3d2616c993e10 Mon Sep 17 00:00:00 2001 From: Viktar Basharymau Date: Thu, 22 May 2014 21:16:56 +0300 Subject: 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 ``` --- actionpack/lib/action_dispatch/journey/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') 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) } -- cgit v1.2.3