summaryrefslogtreecommitdiff
path: root/lib/uri/http.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-05 19:09:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-05 19:09:01 +0000
commita5c923f6c1ab0ddd68c4debb7c68623ff0cf4e6a (patch)
tree1e6935db5dd210656930f5353ed892f35ec5b840 /lib/uri/http.rb
parent25d3fc8823cfd11efc6ff732dc9cbe32a7361fe0 (diff)
* lib/uri/http.rb (URI::HTTP#request_uri): optimized.
decrease object allocation, and ensure always create at least one new object for return value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/http.rb')
-rw-r--r--lib/uri/http.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 9877b1ee597..dc47613cdfc 100644
--- a/lib/uri/http.rb
+++ b/lib/uri/http.rb
@@ -93,12 +93,12 @@ module URI
# Otherwise, the path is simply URI#path.
#
def request_uri
- r = path_query
- if r && r[0] != ?/
- r = '/' + r
+ return nil unless @path
+ if @path.start_with?(?/.freeze)
+ @query ? "#@path?#@query" : @path.dup
+ else
+ @query ? "/#@path?#@query" : "/#@path"
end
-
- r
end
end