[前][次][番号順一覧][スレッド一覧]

ruby-changes:58447

From: Jeremy <ko1@a...>
Date: Sat, 26 Oct 2019 09:46:23 +0900 (JST)
Subject: [ruby-changes:58447] 0098977053 (master): [ruby/forwardable] Remove string allocation in def_{instance, single}_delegators

https://git.ruby-lang.org/ruby.git/commit/?id=0098977053

From 00989770535cfe69e618a2c556dad44610042e13 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Wed, 21 Aug 2019 07:33:28 -0700
Subject: [ruby/forwardable] Remove string allocation in
 def_{instance,single}_delegators

https://github.com/ruby/forwardable/commit/1a994c90e1

diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 3ca8a25..924c605 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -150,7 +150,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L150
   #
   def def_instance_delegators(accessor, *methods)
     methods.each do |method|
-      next if method.to_s == "__send__" || method.to_s == "__id__"
+      next if /\A__(?:send|id)__\z/ =~ method
       def_instance_delegator(accessor, method)
     end
   end
@@ -286,7 +286,7 @@ module SingleForwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L286
   #
   def def_single_delegators(accessor, *methods)
     methods.each do |method|
-      next if method.to_s == "__send__" || method.to_s == "__id__"
+      next if /\A__(?:send|id)__\z/ =~ method
       def_single_delegator(accessor, method)
     end
   end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]