Skip to content
Browse files

Avoid hash lookups for building an array of required defaults

Only set the value once after it's calculated.
  • Loading branch information...
1 parent 3f2bf0d commit 00adce4ff0b44865a7b3b7cec391220487e88565 @carlosantoniodasilva carlosantoniodasilva committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 actionpack/lib/action_dispatch/routing/mapper.rb
View
5 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -176,12 +176,13 @@ def normalize_conditions!
end
end
- @conditions[:required_defaults] = []
+ required_defaults = []
options.each do |key, required_default|
unless segment_keys.include?(key) || IGNORE_OPTIONS.include?(key) || Regexp === required_default
- @conditions[:required_defaults] << key
+ required_defaults << key
end
end
+ @conditions[:required_defaults] = required_defaults
via_all = options.delete(:via) if options[:via] == :all

0 comments on commit 00adce4

Please sign in to comment.
Something went wrong with that request. Please try again.