* lib/uri/generic.rb (URI::Generic#normalize!): use String#empty?

* lib/uri/generic.rb (URI::Generic#path_query): optimized.

* lib/uri/generic.rb (URI::Generic#to_s): optimized.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-08-05 19:09:05 +00:00
parent a5c923f6c1
commit d7b5ef028b
2 changed files with 20 additions and 16 deletions

View File

@ -1,3 +1,11 @@
Wed Aug 6 01:15:47 2014 NARUSE, Yui <naruse@ruby-lang.org>
* lib/uri/generic.rb (URI::Generic#normalize!): use String#empty?
* lib/uri/generic.rb (URI::Generic#path_query): optimized.
* lib/uri/generic.rb (URI::Generic#to_s): optimized.
Wed Aug 6 00:15:10 2014 NARUSE, Yui <naruse@ruby-lang.org>
* lib/uri/http.rb (URI::HTTP#request_uri): optimized.

View File

@ -1329,7 +1329,7 @@ module URI
# Destructive version of #normalize
#
def normalize!
if path && path == ''
if path && path.empty?
set_path('/')
end
if scheme && scheme != scheme.downcase
@ -1342,11 +1342,7 @@ module URI
# returns the assemble String with path and query components
def path_query
str = @path
if @query
str += '?' + @query
end
str
@query ? "#@path?#@query" : @path
end
private :path_query
@ -1357,36 +1353,36 @@ module URI
str = ''
if @scheme
str << @scheme
str << ':'
str << ':'.freeze
end
if @opaque
str << @opaque
else
if @host
str << '//'
str << '//'.freeze
end
if self.userinfo
str << self.userinfo
str << '@'
str << '@'.freeze
end
if @host
str << @host
end
if @port && @port != self.default_port
str << ':'
str << ':'.freeze
str << @port.to_s
end
str << path_query
str << @path
if @query
str << '?'.freeze
str << @query
end
end
if @fragment
str << '#'
str << '#'.freeze
str << @fragment
end
str
end