aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2019-07-31 12:06:06 +0900
committerAkira Matsuda <ronnie@dio.jp>2019-07-31 17:40:05 +0900
commitacf7642ecec5bdbe6efcb419434b04b35531a2b5 (patch)
tree5f785a757de8d35420839499a2a9c369c786305a /actionpack
parent40fc31c103a92cdfe335066869a54a6961c485ac (diff)
downloadrails-acf7642ecec5bdbe6efcb419434b04b35531a2b5.tar.gz
rails-acf7642ecec5bdbe6efcb419434b04b35531a2b5.tar.bz2
rails-acf7642ecec5bdbe6efcb419434b04b35531a2b5.zip
Reduce some more Hash#fetch + default object allocations
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
index 34b213d14e..237eccf45f 100644
--- a/actionpack/lib/action_dispatch/middleware/ssl.rb
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -126,7 +126,7 @@ module ActionDispatch
[ @redirect.fetch(:status, redirection_status(request)),
{ "Content-Type" => "text/html",
"Location" => https_location_for(request) },
- @redirect.fetch(:body, []) ]
+ (@redirect[:body] || []) ]
end
def redirection_status(request)
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 42e770c5bf..da95e14cbb 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1887,7 +1887,7 @@ module ActionDispatch
options_constraints = options.delete(:constraints) || {}
path_types = paths.group_by(&:class)
- path_types.fetch(String, []).each do |_path|
+ (path_types[String] || []).each do |_path|
route_options = options.dup
if _path && option_path
raise ArgumentError, "Ambiguous route definition. Both :path and the route path were specified as strings."
@@ -1896,7 +1896,7 @@ module ActionDispatch
decomposed_match(_path, controller, route_options, _path, to, via, formatted, anchor, options_constraints)
end
- path_types.fetch(Symbol, []).each do |action|
+ (path_types[Symbol] || []).each do |action|
route_options = options.dup
decomposed_match(action, controller, route_options, option_path, to, via, formatted, anchor, options_constraints)
end