summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-05-27 12:57:03 +0200
committerJean Boussier <[email protected]>2025-05-27 15:34:02 +0200
commita59835e1d53d3fb673978e93417f4080774f905a (patch)
tree9e270ff8d69e6bee682bcaf93f6b517808880b6a /variable.c
parente535f8248b1ad9f18cfc8134dd7e8056d97a6244 (diff)
Refactor `rb_shape_get_iv_index` to take a `shape_id_t`
Further reduce exposure of `rb_shape_t`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13450
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/variable.c b/variable.c
index e8aedc5ac0..8ee3376de6 100644
--- a/variable.c
+++ b/variable.c
@@ -1376,8 +1376,6 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
shape_id_t shape_id;
VALUE * ivar_list;
- rb_shape_t * shape;
-
shape_id = RBASIC_SHAPE_ID(obj);
switch (BUILTIN_TYPE(obj)) {
@@ -1399,8 +1397,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
}
else {
attr_index_t index = 0;
- shape = RSHAPE(shape_id);
- found = rb_shape_get_iv_index(shape, id, &index);
+ found = rb_shape_get_iv_index(shape_id, id, &index);
if (found) {
ivar_list = RCLASS_PRIME_FIELDS(obj);
@@ -1463,8 +1460,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
}
attr_index_t index = 0;
- shape = RSHAPE(shape_id);
- if (rb_shape_get_iv_index(shape, id, &index)) {
+ if (rb_shape_get_iv_index(shape_id, id, &index)) {
return ivar_list[index];
}
@@ -1717,15 +1713,16 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
.existing = true
};
- rb_shape_t *current_shape = rb_obj_shape(obj);
+ shape_id_t current_shape_id = RBASIC_SHAPE_ID(obj);
- if (UNLIKELY(rb_shape_too_complex_p(current_shape))) {
+ if (UNLIKELY(rb_shape_id_too_complex_p(current_shape_id))) {
goto too_complex;
}
attr_index_t index;
- if (!rb_shape_get_iv_index(current_shape, id, &index)) {
+ if (!rb_shape_get_iv_index(current_shape_id, id, &index)) {
result.existing = false;
+ rb_shape_t *current_shape = RSHAPE(current_shape_id);
index = current_shape->next_field_index;
if (index >= SHAPE_MAX_FIELDS) {
@@ -2172,7 +2169,7 @@ rb_ivar_defined(VALUE obj, ID id)
return Qtrue;
}
else {
- return RBOOL(rb_shape_get_iv_index(rb_obj_shape(obj), id, &index));
+ return RBOOL(rb_shape_get_iv_index(RBASIC_SHAPE_ID(obj), id, &index));
}
}