aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-11 11:36:50 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-11 11:36:50 -0700
commitaaaff369da1ebc83fe2a202e5bbbd98c1eda2f42 (patch)
tree6b4626c0fbdaf2706bb17274f5a24694b93a1053 /actionpack
parent1c432d1af1399e23fdff8f80bb203da8d3b7cc78 (diff)
downloadrails-aaaff369da1ebc83fe2a202e5bbbd98c1eda2f42.tar.gz
rails-aaaff369da1ebc83fe2a202e5bbbd98c1eda2f42.tar.bz2
rails-aaaff369da1ebc83fe2a202e5bbbd98c1eda2f42.zip
cache protocol on the stack to reduce options hash lookups
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index c4fd05481a..6444fa6f78 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -79,17 +79,17 @@ module ActionDispatch
options[:port] = match[3] unless options.key?(:port)
end
- options[:protocol] = normalize_protocol(options)
- options[:host] = normalize_host(options)
+ protocol = normalize_protocol options[:protocol]
+ options[:host] = normalize_host(options)
- result = options[:protocol].dup
+ result = protocol.dup
if options[:user] && options[:password]
result << "#{Rack::Utils.escape(options[:user])}:#{Rack::Utils.escape(options[:password])}@"
end
result << options[:host]
- normalize_port(options[:port], options[:protocol]) { |port|
+ normalize_port(options[:port], protocol) { |port|
result << ":#{port}"
}
@@ -104,8 +104,8 @@ module ActionDispatch
(options[:subdomain] == true || !options.key?(:subdomain)) && options[:domain].nil?
end
- def normalize_protocol(options)
- case options[:protocol]
+ def normalize_protocol(protocol)
+ case protocol
when nil
"http://"
when false, "//"
@@ -113,7 +113,7 @@ module ActionDispatch
when PROTOCOL_REGEXP
"#{$1}://"
else
- raise ArgumentError, "Invalid :protocol option: #{options[:protocol].inspect}"
+ raise ArgumentError, "Invalid :protocol option: #{protocol.inspect}"
end
end