ruby-changes:45840
From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 23:57:25 +0900 (JST)
Subject: [ruby-changes:45840] naruse:r57913 (ruby_2_4): merge revision(s) 57255, 57256, 57257: [Backport #13111]
naruse 2017-03-12 23:57:21 +0900 (Sun, 12 Mar 2017) New Revision: 57913 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57913 Log: merge revision(s) 57255,57256,57257: [Backport #13111] forwardable.rb: use defined? * lib/forwardable.rb (_delegator_method): use defined? operator instead of binding and calling unbound Kernel#respond_to?. a remedy for an performance bottleneck. forwardable.rb: use defined? * lib/forwardable.rb (_delegator_method): use defined? operator instead of binding and calling unbound Kernel#respond_to?. a remedy for an performance bottleneck. forwardable.rb: fix branches * lib/forwardable.rb (instance_delegate, single_delegate): fix inverted branches. Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/lib/forwardable.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 57912) +++ ruby_2_4/version.h (revision 57913) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.0" #define RUBY_RELEASE_DATE "2017-03-12" -#define RUBY_PATCHLEVEL 69 +#define RUBY_PATCHLEVEL 70 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/lib/forwardable.rb =================================================================== --- ruby_2_4/lib/forwardable.rb (revision 57912) +++ ruby_2_4/lib/forwardable.rb (revision 57913) @@ -130,12 +130,13 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/forwardable.rb#L130 # delegate [method, method, ...] => accessor # def instance_delegate(hash) - hash.each{ |methods, accessor| - methods = [methods] unless methods.respond_to?(:each) - methods.each{ |method| - def_instance_delegator(accessor, method) - } - } + hash.each do |methods, accessor| + unless defined?(methods.each) + def_instance_delegator(accessor, methods) + else + methods.each {|method| def_instance_delegator(accessor, method)} + end + end end # @@ -204,7 +205,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/forwardable.rb#L205 mesg = "#{Module === obj ? obj : obj.class}\##{ali} at #{loc.path}:#{loc.lineno} forwarding to private method " method_call = "#{<<-"begin;"}\n#{<<-"end;".chomp}" begin; - unless ::Kernel.instance_method(:respond_to?).bind(_).call(:"#{method}") + unless defined? _.#{method} ::Kernel.warn "\#{caller_locations(1)[0]}: "#{mesg.dump}"\#{_.class}"'##{method}' _#{method_call} else @@ -261,12 +262,13 @@ module SingleForwardable https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/forwardable.rb#L262 # delegate [method, method, ...] => accessor # def single_delegate(hash) - hash.each{ |methods, accessor| - methods = [methods] unless methods.respond_to?(:each) - methods.each{ |method| - def_single_delegator(accessor, method) - } - } + hash.each do |methods, accessor| + unless defined?(methods.each) + def_single_delegator(accessor, methods) + else + methods.each {|method| def_single_delegator(accessor, method)} + end + end end # Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57255-57257 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/