Skip to content

Commit a1f72d2

Browse files
committed
Refactor rb_shape_has_object_id
Now takes a `shape_id_t` and the version that takes a `rb_shape_t *` is private.
1 parent a80a500 commit a1f72d2

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ object_id0(VALUE obj)
18941894
{
18951895
VALUE id = Qfalse;
18961896

1897-
if (rb_shape_id_has_object_id(RBASIC_SHAPE_ID(obj))) {
1897+
if (rb_shape_has_object_id(RBASIC_SHAPE_ID(obj))) {
18981898
shape_id_t object_id_shape_id = rb_shape_transition_object_id(obj);
18991899
id = rb_obj_field_get(obj, object_id_shape_id);
19001900
RUBY_ASSERT(id, "object_id missing");

shape.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -686,16 +686,16 @@ rb_shape_transition_complex(VALUE obj)
686686
return rb_shape_id(shape_transition_too_complex(original_shape));
687687
}
688688

689-
bool
690-
rb_shape_has_object_id(rb_shape_t *shape)
689+
static inline bool
690+
shape_has_object_id(rb_shape_t *shape)
691691
{
692692
return shape->flags & SHAPE_FL_HAS_OBJECT_ID;
693693
}
694694

695695
bool
696-
rb_shape_id_has_object_id(shape_id_t shape_id)
696+
rb_shape_has_object_id(shape_id_t shape_id)
697697
{
698-
return rb_shape_has_object_id(RSHAPE(shape_id));
698+
return shape_has_object_id(RSHAPE(shape_id));
699699
}
700700

701701
shape_id_t
@@ -1081,7 +1081,7 @@ rb_shape_copy_complex_ivars(VALUE dest, VALUE obj, shape_id_t src_shape_id, st_t
10811081
{
10821082
// obj is TOO_COMPLEX so we can copy its iv_hash
10831083
st_table *table = st_copy(fields_table);
1084-
if (rb_shape_id_has_object_id(src_shape_id)) {
1084+
if (rb_shape_has_object_id(src_shape_id)) {
10851085
st_data_t id = (st_data_t)ruby_internal_object_id;
10861086
st_delete(table, &id, NULL);
10871087
}
@@ -1155,11 +1155,11 @@ shape_frozen(VALUE self)
11551155
}
11561156

11571157
static VALUE
1158-
shape_has_object_id(VALUE self)
1158+
shape_has_object_id_p(VALUE self)
11591159
{
11601160
shape_id_t shape_id = NUM2INT(rb_struct_getmember(self, rb_intern("id")));
11611161
rb_shape_t *shape = RSHAPE(shape_id);
1162-
return RBOOL(rb_shape_has_object_id(shape));
1162+
return RBOOL(shape_has_object_id(shape));
11631163
}
11641164

11651165
static VALUE
@@ -1467,7 +1467,7 @@ Init_shape(void)
14671467
rb_define_method(rb_cShape, "depth", rb_shape_export_depth, 0);
14681468
rb_define_method(rb_cShape, "too_complex?", shape_too_complex, 0);
14691469
rb_define_method(rb_cShape, "shape_frozen?", shape_frozen, 0);
1470-
rb_define_method(rb_cShape, "has_object_id?", shape_has_object_id, 0);
1470+
rb_define_method(rb_cShape, "has_object_id?", shape_has_object_id_p, 0);
14711471

14721472
rb_define_const(rb_cShape, "SHAPE_ROOT", INT2NUM(SHAPE_ROOT));
14731473
rb_define_const(rb_cShape, "SHAPE_IVAR", INT2NUM(SHAPE_IVAR));

shape.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *v
127127
RUBY_FUNC_EXPORTED bool rb_shape_obj_too_complex_p(VALUE obj);
128128
bool rb_shape_too_complex_p(rb_shape_t *shape);
129129
bool rb_shape_id_too_complex_p(shape_id_t shape_id);
130-
bool rb_shape_has_object_id(rb_shape_t *shape);
131-
bool rb_shape_id_has_object_id(shape_id_t shape_id);
130+
bool rb_shape_has_object_id(shape_id_t shape_id);
132131

133132
shape_id_t rb_shape_transition_frozen(VALUE obj);
134133
shape_id_t rb_shape_transition_complex(VALUE obj);
@@ -237,7 +236,7 @@ bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id);
237236
static inline bool
238237
rb_shape_obj_has_id(VALUE obj)
239238
{
240-
return rb_shape_id_has_object_id(RBASIC_SHAPE_ID(obj));
239+
return rb_shape_has_object_id(RBASIC_SHAPE_ID(obj));
241240
}
242241

243242
// For ext/objspace

0 commit comments

Comments
 (0)