aboutsummaryrefslogtreecommitdiffstats
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
parent25d3fc8823cfd11efc6ff732dc9cbe32a7361fe0 (diff)
downloadruby-a5c923f6c1ab0ddd68c4debb7c68623ff0cf4e6a.tar.gz
* 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
-rw-r--r--ChangeLog6
-rw-r--r--lib/uri/http.rb10
2 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bfda8be1af..bb85fc2934 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Aug 6 00:15:10 2014 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * lib/uri/http.rb (URI::HTTP#request_uri): optimized.
+ decrease object allocation, and ensure always create at least one new
+ object for return value.
+
Wed Aug 6 03:41:21 2014 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 9877b1ee59..dc47613cdf 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