1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use caller with length to reduce unused strings

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2017-10-21 14:40:03 +00:00
parent 4c6eb271dd
commit dabdec31e4
7 changed files with 20 additions and 20 deletions

View file

@ -201,7 +201,7 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
if /(?<type>_client|_server)\z/ =~ meth if /(?<type>_client|_server)\z/ =~ meth
meth = $` meth = $`
if $VERBOSE 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
end end
version = METHODS_MAP[meth.intern] or version = METHODS_MAP[meth.intern] or

View file

@ -97,7 +97,7 @@ class Delegator < BasicObject
target = self.__getobj__ {r = false} target = self.__getobj__ {r = false}
r &&= target.respond_to?(m, include_private) r &&= target.respond_to?(m, include_private)
if r && include_private && !target.respond_to?(m, false) 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 return false
end end
r r

View file

@ -310,7 +310,7 @@ class IPAddr
# Returns true if the ipaddr is an IPv4-compatible IPv6 address. # Returns true if the ipaddr is an IPv4-compatible IPv6 address.
def ipv4_compat? 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? _ipv4_compat?
end end
@ -336,7 +336,7 @@ class IPAddr
# Returns a new ipaddr built by converting the native IPv4 address # Returns a new ipaddr built by converting the native IPv4 address
# into an IPv4-compatible IPv6 address. # into an IPv4-compatible IPv6 address.
def ipv4_compat 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? if !ipv4?
raise InvalidAddressError, "not an IPv4 address" raise InvalidAddressError, "not an IPv4 address"
end end

View file

@ -1246,7 +1246,7 @@ class Matrix
# deprecated; use Matrix#determinant # deprecated; use Matrix#determinant
# #
def determinant_e 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 determinant
end end
alias det_e determinant_e alias det_e determinant_e
@ -1304,7 +1304,7 @@ class Matrix
# deprecated; use Matrix#rank # deprecated; use Matrix#rank
# #
def rank_e 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 rank
end end
@ -1490,17 +1490,17 @@ class Matrix
end end
def elements_to_f 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) map(&:to_f)
end end
def elements_to_i 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) map(&:to_i)
end end
def elements_to_r 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) map(&:to_r)
end end
@ -2142,17 +2142,17 @@ class Vector
end end
def elements_to_f 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) map(&:to_f)
end end
def elements_to_i 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) map(&:to_i)
end end
def elements_to_r 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) map(&:to_r)
end end

View file

@ -140,17 +140,17 @@ class Net::HTTPResponse
# #
def response #:nodoc: 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 self
end end
def header #:nodoc: 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 self
end end
def read_header #:nodoc: 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 self
end end

View file

@ -100,7 +100,7 @@ module URI
# # => "@%3F@%21" # # => "@%3F@%21"
# #
def escape(*arg) 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) DEFAULT_PARSER.escape(*arg)
end end
alias encode escape alias encode escape
@ -132,7 +132,7 @@ module URI
# # => "http://example.com/?a=\t\r" # # => "http://example.com/?a=\t\r"
# #
def unescape(*arg) 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) DEFAULT_PARSER.unescape(*arg)
end end
alias decode unescape alias decode unescape
@ -300,7 +300,7 @@ module URI
# # => ["http://foo.example.com/bla", "mailto:test@example.com"] # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
# #
def self.extract(str, schemes = nil, &block) 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) DEFAULT_PARSER.extract(str, schemes, &block)
end end
@ -336,7 +336,7 @@ module URI
# end # end
# #
def self.regexp(schemes = nil) 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) DEFAULT_PARSER.make_regexp(schemes)
end end

View file

@ -842,7 +842,7 @@ module Test
begin begin
require "rbconfig" require "rbconfig"
rescue LoadError 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 options[:parallel] = nil
else else
options[:ruby] ||= [RbConfig.ruby] options[:ruby] ||= [RbConfig.ruby]