diff options
author | schneems <richard.schneeman@gmail.com> | 2015-07-30 12:34:48 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2015-07-30 12:34:48 -0500 |
commit | 22f592401444a83b7b2d3c2165ac666d69955d08 (patch) | |
tree | 7a17fb1c71c4bce7a6c1d08c7307be6ceb721f6f /actionpack/lib | |
parent | 61dae882546f643050c47e573161a467e156c704 (diff) | |
download | rails-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')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/formatter.rb | 5 |
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 |