Skip to content

Commit ffa99e4

Browse files
committed
shape.c: cleanup unused IDs
id_frozen and id_t_object are no longer used. id_object_id no longer need to be exposed.
1 parent dd4c5ac commit ffa99e4

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

shape.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
#define MAX_SHAPE_ID (SHAPE_BUFFER_SIZE - 1)
3434
#define ANCESTOR_SEARCH_MAX_DEPTH 2
3535

36-
static ID id_frozen;
37-
static ID id_t_object;
38-
ID ruby_internal_object_id; // extern
36+
static ID id_object_id;
3937

4038
#define LEAF 0
4139
#define BLACK 0x0
@@ -714,7 +712,7 @@ shape_transition_object_id(shape_id_t original_shape_id)
714712
RUBY_ASSERT(!rb_shape_has_object_id(original_shape_id));
715713

716714
bool dont_care;
717-
rb_shape_t *shape = get_next_shape_internal(RSHAPE(original_shape_id), ruby_internal_object_id, SHAPE_OBJ_ID, &dont_care, true);
715+
rb_shape_t *shape = get_next_shape_internal(RSHAPE(original_shape_id), id_object_id, SHAPE_OBJ_ID, &dont_care, true);
718716
if (!shape) {
719717
shape = RSHAPE(ROOT_SHAPE_WITH_OBJ_ID);
720718
}
@@ -1146,7 +1144,7 @@ rb_shape_copy_complex_ivars(VALUE dest, VALUE obj, shape_id_t src_shape_id, st_t
11461144
// obj is TOO_COMPLEX so we can copy its iv_hash
11471145
st_table *table = st_copy(fields_table);
11481146
if (rb_shape_has_object_id(src_shape_id)) {
1149-
st_data_t id = (st_data_t)ruby_internal_object_id;
1147+
st_data_t id = (st_data_t)id_object_id;
11501148
st_delete(table, &id, NULL);
11511149
}
11521150
rb_obj_init_too_complex(dest, table);
@@ -1497,9 +1495,7 @@ Init_default_shapes(void)
14971495
rb_memerror();
14981496
}
14991497

1500-
id_frozen = rb_make_internal_id();
1501-
id_t_object = rb_make_internal_id();
1502-
ruby_internal_object_id = rb_make_internal_id();
1498+
id_object_id = rb_make_internal_id();
15031499

15041500
#ifdef HAVE_MMAP
15051501
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)
15291525
rb_shape_tree.root_shape = root;
15301526
RUBY_ASSERT(raw_shape_id(rb_shape_tree.root_shape) == ROOT_SHAPE_ID);
15311527

1532-
rb_shape_t *root_with_obj_id = rb_shape_alloc_with_parent_id(0, ROOT_SHAPE_ID);
1533-
root_with_obj_id->type = SHAPE_OBJ_ID;
1534-
root_with_obj_id->edge_name = ruby_internal_object_id;
1535-
root_with_obj_id->next_field_index++;
1528+
bool dontcare;
1529+
rb_shape_t *root_with_obj_id = get_next_shape_internal(root, id_object_id, SHAPE_OBJ_ID, &dontcare, true);
15361530
RUBY_ASSERT(raw_shape_id(root_with_obj_id) == ROOT_SHAPE_WITH_OBJ_ID);
1531+
RUBY_ASSERT(root_with_obj_id->type == SHAPE_OBJ_ID);
1532+
RUBY_ASSERT(root_with_obj_id->edge_name == id_object_id);
1533+
RUBY_ASSERT(root_with_obj_id->next_field_index == 1);
15371534
}
15381535

15391536
void

shape.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ typedef uint32_t redblack_id_t;
4545
#define ROOT_TOO_COMPLEX_WITH_OBJ_ID (ROOT_SHAPE_WITH_OBJ_ID | SHAPE_ID_FL_TOO_COMPLEX | SHAPE_ID_FL_HAS_OBJECT_ID)
4646
#define SPECIAL_CONST_SHAPE_ID (ROOT_SHAPE_ID | SHAPE_ID_FL_FROZEN)
4747

48-
extern ID ruby_internal_object_id;
49-
5048
typedef struct redblack_node redblack_node_t;
5149

5250
struct rb_shape {

0 commit comments

Comments
 (0)