summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-09 10:37:28 +0200
committerJean Boussier <[email protected]>2025-06-09 16:38:29 +0200
commitf9966b9b76706705202f83112e0e2dea0237aea1 (patch)
tree6519f4385382e7fb33e71bb5c36eb448b2bb0d4e /gc.c
parente210a70e9a5eb891fe8a999f2f9eb942d295a078 (diff)
Get rid of `gen_fields_tbl.fields_count`
This data is redundant because the shape already contains both the length and capacity of the object's fields. So it both waste space and create the possibility of a desync between the two. We also do not need to initialize everything to Qundef, this seem to be a left-over from pre-shape instance variables.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13561
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 5281e7fb49..98fb13848b 100644
--- a/gc.c
+++ b/gc.c
@@ -4093,7 +4093,8 @@ vm_weak_table_gen_fields_foreach(st_data_t key, st_data_t value, st_data_t data)
);
}
else {
- for (uint32_t i = 0; i < fields_tbl->as.shape.fields_count; i++) {
+ uint32_t fields_count = RSHAPE_LEN(RBASIC_SHAPE_ID((VALUE)key));
+ for (uint32_t i = 0; i < fields_count; i++) {
if (SPECIAL_CONST_P(fields_tbl->as.shape.fields[i])) continue;
int ivar_ret = iter_data->callback(fields_tbl->as.shape.fields[i], iter_data->data);