Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fewer string allocations per url_for

  • Loading branch information...
commit ba487b9bb0fc4fcb02fdf2644cb908cc38263c18 1 parent b610104
@tenderlove tenderlove authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 actionpack/lib/action_dispatch/http/url.rb
View
12 actionpack/lib/action_dispatch/http/url.rb
@@ -37,12 +37,6 @@ def url_for(options)
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 @@ def url_for(options)
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) ?
Please sign in to comment.
Something went wrong with that request. Please try again.