summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-10-31 14:05:37 -0700
committerGitHub <noreply@github.com>2022-10-31 14:05:37 -0700
commit02f15542245222ee392e68fb244b3b8c4a12ad82 (patch)
treeebf3180364aaba5893a17b932605911072189e3d /object.c
parent2b39640b0bbf7459b305d8a98bb01f197975b8d9 (diff)
downloadruby-02f15542245222ee392e68fb244b3b8c4a12ad82.tar.gz
Implement object shapes for T_CLASS and T_MODULE (#6637)
* Avoid RCLASS_IV_TBL in marshal.c * Avoid RCLASS_IV_TBL for class names * Avoid RCLASS_IV_TBL for autoload * Avoid RCLASS_IV_TBL for class variables * Avoid copying RCLASS_IV_TBL onto ICLASSes * Use object shapes for Class and Module IVs
Diffstat (limited to 'object.c')
-rw-r--r--object.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/object.c b/object.c
index aae6cc45a4..5f8568e3b4 100644
--- a/object.c
+++ b/object.c
@@ -298,20 +298,22 @@ init_copy(VALUE dest, VALUE obj)
rb_copy_generic_ivar(dest, obj);
rb_gc_copy_finalizer(dest, obj);
- rb_shape_t *shape_to_set = rb_shape_get_shape(obj);
+ if (!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE)) {
+ rb_shape_t *shape_to_set = rb_shape_get_shape(obj);
- // If the object is frozen, the "dup"'d object will *not* be frozen,
- // so we need to copy the frozen shape's parent to the new object.
- if (rb_shape_frozen_shape_p(shape_to_set)) {
- shape_to_set = rb_shape_get_shape_by_id(shape_to_set->parent_id);
+ // If the object is frozen, the "dup"'d object will *not* be frozen,
+ // so we need to copy the frozen shape's parent to the new object.
+ if (rb_shape_frozen_shape_p(shape_to_set)) {
+ shape_to_set = rb_shape_get_shape_by_id(shape_to_set->parent_id);
+ }
+
+ // shape ids are different
+ rb_shape_set_shape(dest, shape_to_set);
}
if (RB_TYPE_P(obj, T_OBJECT)) {
rb_obj_copy_ivar(dest, obj);
}
-
- // shape ids are different
- rb_shape_set_shape(dest, shape_to_set);
}
static VALUE immutable_obj_clone(VALUE obj, VALUE kwfreeze);