shape.c: cleanup unused IDs

id_frozen and id_t_object are no longer used.
id_object_id no longer need to be exposed.
This commit is contained in:
Jean Boussier 2025-06-13 11:26:24 +02:00
parent dd4c5acc0f
commit 071aa02a4a
Notes: git 2025-06-13 10:03:35 +00:00
2 changed files with 9 additions and 14 deletions

21
shape.c
View file

@ -33,9 +33,7 @@
#define MAX_SHAPE_ID (SHAPE_BUFFER_SIZE - 1)
#define ANCESTOR_SEARCH_MAX_DEPTH 2
static ID id_frozen;
static ID id_t_object;
ID ruby_internal_object_id; // extern
static ID id_object_id;
#define LEAF 0
#define BLACK 0x0
@ -714,7 +712,7 @@ shape_transition_object_id(shape_id_t original_shape_id)
RUBY_ASSERT(!rb_shape_has_object_id(original_shape_id));
bool dont_care;
rb_shape_t *shape = get_next_shape_internal(RSHAPE(original_shape_id), ruby_internal_object_id, SHAPE_OBJ_ID, &dont_care, true);
rb_shape_t *shape = get_next_shape_internal(RSHAPE(original_shape_id), id_object_id, SHAPE_OBJ_ID, &dont_care, true);
if (!shape) {
shape = RSHAPE(ROOT_SHAPE_WITH_OBJ_ID);
}
@ -1146,7 +1144,7 @@ rb_shape_copy_complex_ivars(VALUE dest, VALUE obj, shape_id_t src_shape_id, st_t
// obj is TOO_COMPLEX so we can copy its iv_hash
st_table *table = st_copy(fields_table);
if (rb_shape_has_object_id(src_shape_id)) {
st_data_t id = (st_data_t)ruby_internal_object_id;
st_data_t id = (st_data_t)id_object_id;
st_delete(table, &id, NULL);
}
rb_obj_init_too_complex(dest, table);
@ -1497,9 +1495,7 @@ Init_default_shapes(void)
rb_memerror();
}
id_frozen = rb_make_internal_id();
id_t_object = rb_make_internal_id();
ruby_internal_object_id = rb_make_internal_id();
id_object_id = rb_make_internal_id();
#ifdef HAVE_MMAP
size_t shape_cache_mmap_size = rb_size_mul_or_raise(REDBLACK_CACHE_SIZE, sizeof(redblack_node_t), rb_eRuntimeError);
@ -1529,11 +1525,12 @@ Init_default_shapes(void)
rb_shape_tree.root_shape = root;
RUBY_ASSERT(raw_shape_id(rb_shape_tree.root_shape) == ROOT_SHAPE_ID);
rb_shape_t *root_with_obj_id = rb_shape_alloc_with_parent_id(0, ROOT_SHAPE_ID);
root_with_obj_id->type = SHAPE_OBJ_ID;
root_with_obj_id->edge_name = ruby_internal_object_id;
root_with_obj_id->next_field_index++;
bool dontcare;
rb_shape_t *root_with_obj_id = get_next_shape_internal(root, id_object_id, SHAPE_OBJ_ID, &dontcare, true);
RUBY_ASSERT(raw_shape_id(root_with_obj_id) == ROOT_SHAPE_WITH_OBJ_ID);
RUBY_ASSERT(root_with_obj_id->type == SHAPE_OBJ_ID);
RUBY_ASSERT(root_with_obj_id->edge_name == id_object_id);
RUBY_ASSERT(root_with_obj_id->next_field_index == 1);
}
void

View file

@ -45,8 +45,6 @@ typedef uint32_t redblack_id_t;
#define ROOT_TOO_COMPLEX_WITH_OBJ_ID (ROOT_SHAPE_WITH_OBJ_ID | SHAPE_ID_FL_TOO_COMPLEX | SHAPE_ID_FL_HAS_OBJECT_ID)
#define SPECIAL_CONST_SHAPE_ID (ROOT_SHAPE_ID | SHAPE_ID_FL_FROZEN)
extern ID ruby_internal_object_id;
typedef struct redblack_node redblack_node_t;
struct rb_shape {