aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-20 15:43:46 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-20 15:43:46 -0700
commitba487b9bb0fc4fcb02fdf2644cb908cc38263c18 (patch)
tree6343a652363b75eda8604ffe3ed2b906adb427a8
parentb610104e5ce9c148e67cf7f73c8c3e644b2077f9 (diff)
downloadrails-ba487b9bb0fc4fcb02fdf2644cb908cc38263c18.tar.gz
rails-ba487b9bb0fc4fcb02fdf2644cb908cc38263c18.tar.bz2
rails-ba487b9bb0fc4fcb02fdf2644cb908cc38263c18.zip
fewer string allocations per url_for
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 7ca1636780..a6c17f50a5 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -37,12 +37,6 @@ module ActionDispatch
path = options[:script_name].to_s.chomp("/")
path << options[:path].to_s
- if options[:only_path]
- result = ''
- else
- result = build_host_url(options)
- end
-
if options[:trailing_slash]
if path.include?('?')
path.sub!(/\?/, '/\&')
@@ -51,7 +45,11 @@ module ActionDispatch
end
end
- result << path
+ result = path
+
+ unless options[:only_path]
+ result.prepend build_host_url(options)
+ end
if options.key? :params
params = options[:params].is_a?(Hash) ?