From 11ad7f5f47b4e4919bcf7a03338a62ef5b5396cc Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 20 May 2025 13:10:41 -0700 Subject: Don't use namespaced classext for superclasses Superclasses can't be modified by user code, so do not need namespace indirection. For example Object.superclass is always BasicObject, no matter what modules are included onto it. --- class.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'class.c') diff --git a/class.c b/class.c index 1e436e6c96..ba57d8a39d 100644 --- a/class.c +++ b/class.c @@ -183,16 +183,6 @@ duplicate_classext_const_tbl(struct rb_id_table *src, VALUE klass) return dst; } -static void -duplicate_classext_superclasses(rb_classext_t *orig, rb_classext_t *copy) -{ - RCLASSEXT_SUPERCLASSES(copy) = RCLASSEXT_SUPERCLASSES(orig); - RCLASSEXT_SUPERCLASS_DEPTH(copy) = RCLASSEXT_SUPERCLASS_DEPTH(orig); - // the copy is always not the owner and the orig (or its parent class) will maintain the superclasses array - RCLASSEXT_SUPERCLASSES_OWNER(copy) = false; - RCLASSEXT_SUPERCLASSES_WITH_SELF(copy) = RCLASSEXT_SUPERCLASSES_WITH_SELF(orig); -} - static VALUE namespace_subclasses_tbl_key(const rb_namespace_t *ns) { @@ -349,9 +339,6 @@ rb_class_duplicate_classext(rb_classext_t *orig, VALUE klass, const rb_namespace RCLASSEXT_CVC_TBL(ext) = duplicate_classext_id_table(RCLASSEXT_CVC_TBL(orig), dup_iclass); - // superclass_depth, superclasses - duplicate_classext_superclasses(orig, ext); - // subclasses, subclasses_index duplicate_classext_subclasses(orig, ext); @@ -832,11 +819,11 @@ rb_class_update_superclasses(VALUE klass) } else { superclasses = class_superclasses_including_self(super); - RCLASS_WRITE_SUPERCLASSES(super, super_depth, superclasses, true, true); + RCLASS_WRITE_SUPERCLASSES(super, super_depth, superclasses, true); } size_t depth = super_depth == RCLASS_MAX_SUPERCLASS_DEPTH ? super_depth : super_depth + 1; - RCLASS_WRITE_SUPERCLASSES(klass, depth, superclasses, false, false); + RCLASS_WRITE_SUPERCLASSES(klass, depth, superclasses, false); } void -- cgit v1.2.3