summaryrefslogtreecommitdiff
path: root/shape.c
diff options
context:
space:
mode:
authorHParker <[email protected]>2023-02-17 08:15:03 -0800
committerAaron Patterson <[email protected]>2023-03-09 15:34:49 -0800
commit69465df4242f3b2d8e55fbe18d7c45b47b40a626 ()
tree57aad5e76cfff0615df51443ede9b010d1c4f2f4 /shape.c
parent65a95b82593683ba2e566fe1d14b086b80874c92 (diff)
Allow classes and modules to become too complex
This makes the behavior of classes and modules when there are too many instance variables match the behavior of objects with too many instance variables.
Notes: Merged: https://.com/ruby/ruby/pull/7349
-rw-r--r--shape.c16
1 files changed, 11 insertions, 5 deletions
@@ -239,7 +239,7 @@ remove_shape_recursive(VALUE obj, ID id, rb_shape_t * shape, VALUE * removed)
if (new_parent) {
bool dont_care;
enum ruby_value_type type = BUILTIN_TYPE(obj);
- bool new_shape_necessary = type != T_OBJECT;
rb_shape_t * new_child = get_next_shape_internal(new_parent, shape->edge_name, shape->type, &dont_care, true, new_shape_necessary);
new_child->capacity = shape->capacity;
if (new_child->type == SHAPE_IVAR) {
@@ -316,12 +316,10 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id)
}
bool variation_created = false;
- // For non T_OBJECTS, force a new shape
- bool new_shape_necessary = BUILTIN_TYPE(obj) != T_OBJECT;
rb_shape_t * new_shape = get_next_shape_internal(shape, id, SHAPE_IVAR, &variation_created, allow_new_shape, new_shape_necessary);
if (!new_shape) {
- RUBY_ASSERT(BUILTIN_TYPE(obj) == T_OBJECT);
new_shape = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID);
}
@@ -336,6 +334,15 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id)
RCLASS_EXT(klass)->variation_count++;
}
}
return new_shape;
}
@@ -523,7 +530,6 @@ rb_shape_obj_too_complex(VALUE obj)
void
rb_shape_set_too_complex(VALUE obj)
{
- RUBY_ASSERT(BUILTIN_TYPE(obj) == T_OBJECT);
RUBY_ASSERT(!rb_shape_obj_too_complex(obj));
rb_shape_set_shape_id(obj, OBJ_TOO_COMPLEX_SHAPE_ID);
}