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

ruby-changes:67199

From: Nobuyoshi <ko1@a...>
Date: Fri, 20 Aug 2021 14:08:38 +0900 (JST)
Subject: [ruby-changes:67199] b32987a3d7 (master): Simplify repeated member access macros

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

From b32987a3d783d6c7a5dec9a9a9c3550ca7c549d0 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 20 Aug 2021 14:03:08 +0900
Subject: Simplify repeated member access macros

---
 class.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/class.c b/class.c
index 9e5cf54..5fa51df 100644
--- a/class.c
+++ b/class.c
@@ -89,14 +89,14 @@ rb_module_add_to_subclasses_list(VALUE module, VALUE iclass) https://github.com/ruby/ruby/blob/trunk/class.c#L89
 void
 rb_class_remove_from_super_subclasses(VALUE klass)
 {
-    rb_subclass_entry_t *entry;
+    rb_subclass_entry_t **prev = RCLASS_PARENT_SUBCLASSES(klass);
 
-    if (RCLASS_PARENT_SUBCLASSES(klass)) {
-	entry = *RCLASS_PARENT_SUBCLASSES(klass);
+    if (prev) {
+	rb_subclass_entry_t *entry = *prev, *next = entry->next;
 
-	*RCLASS_PARENT_SUBCLASSES(klass) = entry->next;
-	if (entry->next) {
-	    RCLASS_PARENT_SUBCLASSES(entry->next->klass) = RCLASS_PARENT_SUBCLASSES(klass);
+	*prev = next;
+	if (next) {
+	    RCLASS_PARENT_SUBCLASSES(next->klass) = prev;
 	}
 	xfree(entry);
     }
@@ -107,14 +107,14 @@ rb_class_remove_from_super_subclasses(VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L107
 void
 rb_class_remove_from_module_subclasses(VALUE klass)
 {
-    rb_subclass_entry_t *entry;
+    rb_subclass_entry_t **prev = RCLASS_MODULE_SUBCLASSES(klass);
 
-    if (RCLASS_MODULE_SUBCLASSES(klass)) {
-	entry = *RCLASS_MODULE_SUBCLASSES(klass);
-	*RCLASS_MODULE_SUBCLASSES(klass) = entry->next;
+    if (prev) {
+        rb_subclass_entry_t *entry = *prev, *next = entry->next;
 
-	if (entry->next) {
-	    RCLASS_MODULE_SUBCLASSES(entry->next->klass) = RCLASS_MODULE_SUBCLASSES(klass);
+	*prev = next;
+	if (next) {
+	    RCLASS_MODULE_SUBCLASSES(next->klass) = prev;
 	}
 
 	xfree(entry);
@@ -1124,10 +1124,10 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super https://github.com/ruby/ruby/blob/trunk/class.c#L1124
             add_subclass = FALSE;
         }
 
-	{
+	if (add_subclass) {
 	    VALUE m = module;
             if (BUILTIN_TYPE(m) == T_ICLASS) m = RBASIC(m)->klass;
-            if (add_subclass) rb_module_add_to_subclasses_list(m, iclass);
+            rb_module_add_to_subclasses_list(m, iclass);
 	}
 
 	if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
-- 
cgit v1.1


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

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