ruby-changes:48173
From: kazu <ko1@a...>
Date: Sat, 21 Oct 2017 23:40:08 +0900 (JST)
Subject: [ruby-changes:48173] kazu:r60288 (trunk): Use caller with length to reduce unused strings
kazu 2017-10-21 23:40:03 +0900 (Sat, 21 Oct 2017) New Revision: 60288 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60288 Log: Use caller with length to reduce unused strings Modified files: trunk/ext/openssl/lib/openssl/ssl.rb trunk/lib/delegate.rb trunk/lib/ipaddr.rb trunk/lib/matrix.rb trunk/lib/net/http/response.rb trunk/lib/uri/common.rb trunk/test/lib/test/unit.rb Index: lib/net/http/response.rb =================================================================== --- lib/net/http/response.rb (revision 60287) +++ lib/net/http/response.rb (revision 60288) @@ -140,17 +140,17 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/lib/net/http/response.rb#L140 # def response #:nodoc: - warn "#{caller(1)[0]}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE self end def header #:nodoc: - warn "#{caller(1)[0]}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE self end def read_header #:nodoc: - warn "#{caller(1)[0]}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE self end Index: lib/matrix.rb =================================================================== --- lib/matrix.rb (revision 60287) +++ lib/matrix.rb (revision 60288) @@ -1246,7 +1246,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1246 # deprecated; use Matrix#determinant # def determinant_e - warn "#{caller(1)[0]}: warning: Matrix#determinant_e is deprecated; use #determinant" + warn "#{caller(1, 1)[0]}: warning: Matrix#determinant_e is deprecated; use #determinant" determinant end alias det_e determinant_e @@ -1304,7 +1304,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1304 # deprecated; use Matrix#rank # def rank_e - warn "#{caller(1)[0]}: warning: Matrix#rank_e is deprecated; use #rank" + warn "#{caller(1, 1)[0]}: warning: Matrix#rank_e is deprecated; use #rank" rank end @@ -1490,17 +1490,17 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1490 end def elements_to_f - warn "#{caller(1)[0]}: warning: Matrix#elements_to_f is deprecated, use map(&:to_f)" + warn "#{caller(1, 1)[0]}: warning: Matrix#elements_to_f is deprecated, use map(&:to_f)" map(&:to_f) end def elements_to_i - warn "#{caller(1)[0]}: warning: Matrix#elements_to_i is deprecated, use map(&:to_i)" + warn "#{caller(1, 1)[0]}: warning: Matrix#elements_to_i is deprecated, use map(&:to_i)" map(&:to_i) end def elements_to_r - warn "#{caller(1)[0]}: warning: Matrix#elements_to_r is deprecated, use map(&:to_r)" + warn "#{caller(1, 1)[0]}: warning: Matrix#elements_to_r is deprecated, use map(&:to_r)" map(&:to_r) end @@ -2142,17 +2142,17 @@ class Vector https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L2142 end def elements_to_f - warn "#{caller(1)[0]}: warning: Vector#elements_to_f is deprecated" + warn "#{caller(1, 1)[0]}: warning: Vector#elements_to_f is deprecated" map(&:to_f) end def elements_to_i - warn "#{caller(1)[0]}: warning: Vector#elements_to_i is deprecated" + warn "#{caller(1, 1)[0]}: warning: Vector#elements_to_i is deprecated" map(&:to_i) end def elements_to_r - warn "#{caller(1)[0]}: warning: Vector#elements_to_r is deprecated" + warn "#{caller(1, 1)[0]}: warning: Vector#elements_to_r is deprecated" map(&:to_r) end Index: lib/ipaddr.rb =================================================================== --- lib/ipaddr.rb (revision 60287) +++ lib/ipaddr.rb (revision 60288) @@ -310,7 +310,7 @@ class IPAddr https://github.com/ruby/ruby/blob/trunk/lib/ipaddr.rb#L310 # Returns true if the ipaddr is an IPv4-compatible IPv6 address. def ipv4_compat? - warn "#{caller(1)[0]}: warning: IPAddr\##{__callee__} is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: IPAddr\##{__callee__} is obsolete" if $VERBOSE _ipv4_compat? end @@ -336,7 +336,7 @@ class IPAddr https://github.com/ruby/ruby/blob/trunk/lib/ipaddr.rb#L336 # Returns a new ipaddr built by converting the native IPv4 address # into an IPv4-compatible IPv6 address. def ipv4_compat - warn "#{caller(1)[0]}: warning: IPAddr\##{__callee__} is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: IPAddr\##{__callee__} is obsolete" if $VERBOSE if !ipv4? raise InvalidAddressError, "not an IPv4 address" end Index: lib/delegate.rb =================================================================== --- lib/delegate.rb (revision 60287) +++ lib/delegate.rb (revision 60288) @@ -97,7 +97,7 @@ class Delegator < BasicObject https://github.com/ruby/ruby/blob/trunk/lib/delegate.rb#L97 target = self.__getobj__ {r = false} r &&= target.respond_to?(m, include_private) if r && include_private && !target.respond_to?(m, false) - warn "#{caller(3)[0]}: delegator does not forward private method \##{m}" + warn "#{caller(3, 1)[0]}: delegator does not forward private method \##{m}" return false end r Index: lib/uri/common.rb =================================================================== --- lib/uri/common.rb (revision 60287) +++ lib/uri/common.rb (revision 60288) @@ -100,7 +100,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb#L100 # # => "@%3F@%21" # def escape(*arg) - warn "#{caller(1)[0]}: warning: URI.escape is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: URI.escape is obsolete" if $VERBOSE DEFAULT_PARSER.escape(*arg) end alias encode escape @@ -132,7 +132,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb#L132 # # => "http://example.com/?a=\t\r" # def unescape(*arg) - warn "#{caller(1)[0]}: warning: URI.unescape is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: URI.unescape is obsolete" if $VERBOSE DEFAULT_PARSER.unescape(*arg) end alias decode unescape @@ -300,7 +300,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb#L300 # # => ["http://foo.example.com/bla", "mailto:test@e..."] # def self.extract(str, schemes = nil, &block) - warn "#{caller(1)[0]}: warning: URI.extract is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: URI.extract is obsolete" if $VERBOSE DEFAULT_PARSER.extract(str, schemes, &block) end @@ -336,7 +336,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb#L336 # end # def self.regexp(schemes = nil) - warn "#{caller(1)[0]}: warning: URI.regexp is obsolete" if $VERBOSE + warn "#{caller(1, 1)[0]}: warning: URI.regexp is obsolete" if $VERBOSE DEFAULT_PARSER.make_regexp(schemes) end Index: test/lib/test/unit.rb =================================================================== --- test/lib/test/unit.rb (revision 60287) +++ test/lib/test/unit.rb (revision 60288) @@ -842,7 +842,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L842 begin require "rbconfig" rescue LoadError - warn "#{caller(1)[0]}: warning: Parallel running disabled because can't get path to ruby; run specify with --ruby argument" + warn "#{caller(1, 1)[0]}: warning: Parallel running disabled because can't get path to ruby; run specify with --ruby argument" options[:parallel] = nil else options[:ruby] ||= [RbConfig.ruby] Index: ext/openssl/lib/openssl/ssl.rb =================================================================== --- ext/openssl/lib/openssl/ssl.rb (revision 60287) +++ ext/openssl/lib/openssl/ssl.rb (revision 60288) @@ -201,7 +201,7 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9ekn https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/ssl.rb#L201 if /(?<type>_client|_server)\z/ =~ meth meth = $` if $VERBOSE - warn "#{caller(1)[0]}: method type #{type.inspect} is ignored" + warn "#{caller(1, 1)[0]}: method type #{type.inspect} is ignored" end end version = METHODS_MAP[meth.intern] or -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/