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

ruby-changes:61984

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:27 +0900 (JST)
Subject: [ruby-changes:61984] 86e3d63772 (master): SPECIAL_SINGLETON: no longer used

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

From 86e3d63772533d6b301ab0d9e73b719c47d96f7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Fri, 12 Jun 2020 12:35:45 +0900
Subject: SPECIAL_SINGLETON: no longer used

This macro does not improve any readability and/or runtime performance.

diff --git a/class.c b/class.c
index 7719b06..47bb562 100644
--- a/class.c
+++ b/class.c
@@ -1747,19 +1747,15 @@ rb_undef_methods_from(VALUE klass, VALUE super) https://github.com/ruby/ruby/blob/trunk/class.c#L1747
  * \{
  */
 
-#define SPECIAL_SINGLETON(x,c) do {\
-    if (obj == (x)) {\
-	return (c);\
-    }\
-} while (0)
-
 static inline VALUE
 special_singleton_class_of(VALUE obj)
 {
-    SPECIAL_SINGLETON(Qnil, rb_cNilClass);
-    SPECIAL_SINGLETON(Qfalse, rb_cFalseClass);
-    SPECIAL_SINGLETON(Qtrue, rb_cTrueClass);
-    return Qnil;
+    switch (obj) {
+      case Qnil:   return rb_cNilClass;
+      case Qfalse: return rb_cFalseClass;
+      case Qtrue:  return rb_cTrueClass;
+      default:     return Qnil;
+    }
 }
 
 VALUE
-- 
cgit v0.10.2


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

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