aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2015-07-30 12:34:48 -0500
committerschneems <richard.schneeman@gmail.com>2015-07-30 12:34:48 -0500
commit22f592401444a83b7b2d3c2165ac666d69955d08 (patch)
tree7a17fb1c71c4bce7a6c1d08c7307be6ceb721f6f /actionpack/lib/action_dispatch
parent61dae882546f643050c47e573161a467e156c704 (diff)
downloadrails-22f592401444a83b7b2d3c2165ac666d69955d08.tar.gz
rails-22f592401444a83b7b2d3c2165ac666d69955d08.tar.bz2
rails-22f592401444a83b7b2d3c2165ac666d69955d08.zip
Use delete_if instead of each; delete(key)
It is slightly faster: ``` Calculating ------------------------------------- each; delete 35.166k i/100ms delete_if 36.416k i/100ms ------------------------------------------------- each; delete 478.026k (± 8.5%) i/s - 2.391M delete_if 485.123k (± 7.9%) i/s - 2.440M ```
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/journey/formatter.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb
index d6daf5280b..d839fec48d 100644
--- a/actionpack/lib/action_dispatch/journey/formatter.rb
+++ b/actionpack/lib/action_dispatch/journey/formatter.rb
@@ -58,9 +58,8 @@ module ActionDispatch
!options.key?(part) || (options[part] || recall[part]).nil?
} | route.required_parts
- parameterized_parts.each do |bad_key, _|
- next if keys_to_keep.include?(bad_key)
- parameterized_parts.delete(bad_key)
+ parameterized_parts.delete_if do |bad_key, _|
+ !keys_to_keep.include?(bad_key)
end
if parameterize