From a5c923f6c1ab0ddd68c4debb7c68623ff0cf4e6a Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 5 Aug 2014 19:09:01 +0000 Subject: * 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 --- lib/uri/http.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3