ruby-changes:40902
From: normal <ko1@a...>
Date: Wed, 9 Dec 2015 06:30:27 +0900 (JST)
Subject: [ruby-changes:40902] normal:r52981 (trunk): lib/uri/generic.rb: enable frozen_string_literal
normal 2015-12-09 06:28:26 +0900 (Wed, 09 Dec 2015) New Revision: 52981 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52981 Log: lib/uri/generic.rb: enable frozen_string_literal * lib/uri/generic.rb: enable frozen_string_literal (split_userinfo): remove explicit .freeze for string literals (check_path): ditto (query): ditto (fragment): ditto (to_s): ditto [ruby-core:71910] [Bug #11759] Patch-by: Colin Kelley <colindkelley@g...> Modified files: trunk/ChangeLog trunk/lib/uri/generic.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52980) +++ ChangeLog (revision 52981) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 9 06:26:23 2015 Colin Kelley <colindkelley@g...> + + * lib/uri/generic.rb: enable frozen_string_literal + (split_userinfo): remove explicit .freeze for string literals + (check_path): ditto + (query): ditto + (fragment): ditto + (to_s): ditto + [ruby-core:71910] [Bug #11759] + Wed Dec 9 06:25:47 2015 Eric Wong <e@8...> * test/uri/test_generic.rb (to_s): new test Index: lib/uri/generic.rb =================================================================== --- lib/uri/generic.rb (revision 52980) +++ lib/uri/generic.rb (revision 52981) @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1 +# frozen_string_literal: true + # = uri/generic.rb # # Author:: Akira Yamada <akira@r...> @@ -543,7 +545,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L545 # if properly formatted as 'user:password' def split_userinfo(ui) return nil, nil unless ui - user, password = ui.split(':'.freeze, 2) + user, password = ui.split(':', 2) return user, password end @@ -762,13 +764,13 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L764 # If scheme is ftp, path may be relative. # See RFC 1738 section 3.2.2, and RFC 2396. - if @scheme && @scheme != "ftp".freeze - if v && v != ''.freeze && parser.regexp[:ABS_PATH] !~ v + if @scheme && @scheme != "ftp" + if v && v != '' && parser.regexp[:ABS_PATH] !~ v raise InvalidComponentError, "bad component(expected absolute path component): #{v}" end else - if v && v != ''.freeze && parser.regexp[:ABS_PATH] !~ v && + if v && v != '' && parser.regexp[:ABS_PATH] !~ v && parser.regexp[:REL_PATH] !~ v raise InvalidComponentError, "bad component(expected relative path component): #{v}" @@ -844,9 +846,9 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L846 x = v.to_str v = x.dup if x.equal? v v.encode!(Encoding::UTF_8) rescue nil - v.delete!("\t\r\n".freeze) + v.delete!("\t\r\n") v.force_encoding(Encoding::ASCII_8BIT) - v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X'.freeze % $&.ord} + v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord} v.force_encoding(Encoding::US_ASCII) @query = v end @@ -934,9 +936,9 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L936 x = v.to_str v = x.dup if x.equal? v v.encode!(Encoding::UTF_8) rescue nil - v.delete!("\t\r\n".freeze) + v.delete!("\t\r\n") v.force_encoding(Encoding::ASCII_8BIT) - v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X'.freeze % $&.ord} + v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord} v.force_encoding(Encoding::US_ASCII) @fragment = v end @@ -1339,37 +1341,37 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1341 # Constructs String from URI # def to_s - str = '' + str = String.new if @scheme str << @scheme - str << ':'.freeze + str << ':' end if @opaque str << @opaque else if @host - str << '//'.freeze + str << '//' end if self.userinfo str << self.userinfo - str << '@'.freeze + str << '@' end if @host str << @host end if @port && @port != self.default_port - str << ':'.freeze + str << ':' str << @port.to_s end str << @path if @query - str << '?'.freeze + str << '?' str << @query end end if @fragment - str << '#'.freeze + str << '#' str << @fragment end str -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/