Refactor rb_shape_transition_frozen to return a shape_id.

This commit is contained in:
Jean Boussier 2025-05-08 19:05:03 +02:00
parent 31d0a5815c
commit f82523f14b
Notes: git 2025-05-09 08:23:10 +00:00
4 changed files with 21 additions and 21 deletions

View file

@ -519,12 +519,12 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
}
if (RB_OBJ_FROZEN(obj)) {
rb_shape_t *next_shape = rb_shape_transition_shape_frozen(clone);
if (!rb_shape_obj_too_complex(clone) && rb_shape_too_complex_p(next_shape)) {
shape_id_t next_shape_id = rb_shape_transition_frozen(clone);
if (!rb_shape_obj_too_complex(clone) && rb_shape_id_too_complex_p(next_shape_id)) {
rb_evict_ivars_to_hash(clone);
}
else {
rb_shape_set_shape(clone, next_shape);
rb_shape_set_shape_id(clone, next_shape_id);
}
}
break;
@ -541,14 +541,14 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
argv[1] = freeze_true_hash;
rb_funcallv_kw(clone, id_init_clone, 2, argv, RB_PASS_KEYWORDS);
RBASIC(clone)->flags |= FL_FREEZE;
rb_shape_t *next_shape = rb_shape_transition_shape_frozen(clone);
shape_id_t next_shape_id = rb_shape_transition_frozen(clone);
// If we're out of shapes, but we want to freeze, then we need to
// evacuate this clone to a hash
if (!rb_shape_obj_too_complex(clone) && rb_shape_too_complex_p(next_shape)) {
if (!rb_shape_obj_too_complex(clone) && rb_shape_id_too_complex_p(next_shape_id)) {
rb_evict_ivars_to_hash(clone);
}
else {
rb_shape_set_shape(clone, next_shape);
rb_shape_set_shape_id(clone, next_shape_id);
}
break;
}