Skip to content

Commit f1727b5

Browse files
committed
Get rid of rb_obj_set_shape_id
Now that the shape_id has been unified across all types this helper function doesn't do much over `RBASIC_SET_SHAPE_ID`. It still check if the write is needed, but it doesn't seem useful in places where it's used.
1 parent 78b8ecd commit f1727b5

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ rb_gc_get_shape(VALUE obj)
370370
void
371371
rb_gc_set_shape(VALUE obj, uint32_t shape_id)
372372
{
373-
rb_obj_set_shape_id(obj, (uint32_t)shape_id);
373+
RBASIC_SET_SHAPE_ID(obj, (uint32_t)shape_id);
374374
}
375375

376376
uint32_t

object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
362362
}
363363

364364
rb_shape_copy_fields(dest, dest_buf, dest_shape_id, src_buf, src_shape_id);
365-
rb_obj_set_shape_id(dest, dest_shape_id);
365+
RBASIC_SET_SHAPE_ID(dest, dest_shape_id);
366366
}
367367

368368
static void
@@ -496,7 +496,7 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
496496

497497
if (RB_OBJ_FROZEN(obj)) {
498498
shape_id_t next_shape_id = rb_shape_transition_frozen(clone);
499-
rb_obj_set_shape_id(clone, next_shape_id);
499+
RBASIC_SET_SHAPE_ID(clone, next_shape_id);
500500
}
501501
break;
502502
case Qtrue: {

shape.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,6 @@ RBASIC_FIELDS_COUNT(VALUE obj)
380380
return RSHAPE(rb_obj_shape_id(obj))->next_field_index;
381381
}
382382

383-
bool rb_obj_set_shape_id(VALUE obj, shape_id_t shape_id);
384-
385383
static inline bool
386384
rb_shape_obj_has_id(VALUE obj)
387385
{

variable.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
16721672
MEMCPY(ROBJECT_FIELDS(obj), fields, VALUE, new_fields_count);
16731673
xfree(fields);
16741674
}
1675-
rb_obj_set_shape_id(obj, next_shape_id);
1675+
RBASIC_SET_SHAPE_ID(obj, next_shape_id);
16761676

16771677
return val;
16781678

@@ -1925,7 +1925,7 @@ rb_obj_ivar_set(VALUE obj, ID id, VALUE val)
19251925
"next_shape_id: 0x%" PRIx32 " RSHAPE_TYPE(next_shape_id): %d",
19261926
next_shape_id, (int)RSHAPE_TYPE(next_shape_id));
19271927
RUBY_ASSERT(index == (RSHAPE_INDEX(next_shape_id)));
1928-
rb_obj_set_shape_id(obj, next_shape_id);
1928+
RBASIC_SET_SHAPE_ID(obj, next_shape_id);
19291929
}
19301930

19311931
VALUE *table = ROBJECT_FIELDS(obj);
@@ -1971,7 +1971,7 @@ obj_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val)
19711971
}
19721972

19731973
if (RSHAPE_LEN(target_shape_id) > RSHAPE_LEN(current_shape_id)) {
1974-
rb_obj_set_shape_id(obj, target_shape_id);
1974+
RBASIC_SET_SHAPE_ID(obj, target_shape_id);
19751975
}
19761976

19771977
VALUE *table = ROBJECT_FIELDS(obj);
@@ -1991,18 +1991,6 @@ rb_vm_set_ivar_id(VALUE obj, ID id, VALUE val)
19911991
return val;
19921992
}
19931993

1994-
bool
1995-
rb_obj_set_shape_id(VALUE obj, shape_id_t shape_id)
1996-
{
1997-
shape_id_t old_shape_id = rb_obj_shape_id(obj);
1998-
if (old_shape_id == shape_id) {
1999-
return false;
2000-
}
2001-
2002-
RB_SET_SHAPE_ID(obj, shape_id);
2003-
return true;
2004-
}
2005-
20061994
void rb_obj_freeze_inline(VALUE x)
20071995
{
20081996
if (RB_FL_ABLE(x)) {
@@ -2281,7 +2269,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
22812269
}
22822270

22832271
if (!RSHAPE_LEN(dest_shape_id)) {
2284-
rb_obj_set_shape_id(dest, dest_shape_id);
2272+
RBASIC_SET_SHAPE_ID(dest, dest_shape_id);
22852273
return;
22862274
}
22872275

0 commit comments

Comments
 (0)