From ba487b9bb0fc4fcb02fdf2644cb908cc38263c18 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 20 May 2014 15:43:46 -0700 Subject: fewer string allocations per url_for --- actionpack/lib/action_dispatch/http/url.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'actionpack/lib') 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) ? -- cgit v1.2.3