diff options
author | John Hawthorn <[email protected]> | 2025-05-20 13:10:41 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2025-05-23 10:22:24 -0700 |
commit | 11ad7f5f47b4e4919bcf7a03338a62ef5b5396cc () | |
tree | 24b162eff4ed9bdf6c846cb85319e0f99b5c5125 /class.c | |
parent | 1435ea7f44f3d781a03054b4055a1ad2f90dd392 (diff) |
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.
Notes: Merged: https://.com/ruby/ruby/pull/13420
-rw-r--r-- | class.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -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); } size_t depth = super_depth == RCLASS_MAX_SUPERCLASS_DEPTH ? super_depth : super_depth + 1; - RCLASS_WRITE_SUPERCLASSES(klass, depth, superclasses, false, false); } void |