diff options
author | Jean Boussier <[email protected]> | 2025-05-27 13:20:58 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-05-27 15:34:02 +0200 |
commit | a1f72d23a911d8a1f4c89fbaacee1d8e7b4e90d3 (patch) | |
tree | 8e6015e79a7b4f98b99c14917c40acaa4ab518ec | |
parent | a80a5000ab9ac08b9b74cfee559bba5c349b1808 (diff) |
Refactor `rb_shape_has_object_id`
Now takes a `shape_id_t` and the version that takes a `rb_shape_t *`
is private.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | shape.c | 16 | ||||
-rw-r--r-- | shape.h | 5 |
3 files changed, 11 insertions, 12 deletions
@@ -1894,7 +1894,7 @@ object_id0(VALUE obj) { VALUE id = Qfalse; - if (rb_shape_id_has_object_id(RBASIC_SHAPE_ID(obj))) { + if (rb_shape_has_object_id(RBASIC_SHAPE_ID(obj))) { shape_id_t object_id_shape_id = rb_shape_transition_object_id(obj); id = rb_obj_field_get(obj, object_id_shape_id); RUBY_ASSERT(id, "object_id missing"); @@ -686,16 +686,16 @@ rb_shape_transition_complex(VALUE obj) return rb_shape_id(shape_transition_too_complex(original_shape)); } -bool -rb_shape_has_object_id(rb_shape_t *shape) +static inline bool +shape_has_object_id(rb_shape_t *shape) { return shape->flags & SHAPE_FL_HAS_OBJECT_ID; } bool -rb_shape_id_has_object_id(shape_id_t shape_id) +rb_shape_has_object_id(shape_id_t shape_id) { - return rb_shape_has_object_id(RSHAPE(shape_id)); + return shape_has_object_id(RSHAPE(shape_id)); } shape_id_t @@ -1081,7 +1081,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_id_has_object_id(src_shape_id)) { + if (rb_shape_has_object_id(src_shape_id)) { st_data_t id = (st_data_t)ruby_internal_object_id; st_delete(table, &id, NULL); } @@ -1155,11 +1155,11 @@ shape_frozen(VALUE self) } static VALUE -shape_has_object_id(VALUE self) +shape_has_object_id_p(VALUE self) { shape_id_t shape_id = NUM2INT(rb_struct_getmember(self, rb_intern("id"))); rb_shape_t *shape = RSHAPE(shape_id); - return RBOOL(rb_shape_has_object_id(shape)); + return RBOOL(shape_has_object_id(shape)); } static VALUE @@ -1467,7 +1467,7 @@ Init_shape(void) rb_define_method(rb_cShape, "depth", rb_shape_export_depth, 0); rb_define_method(rb_cShape, "too_complex?", shape_too_complex, 0); rb_define_method(rb_cShape, "shape_frozen?", shape_frozen, 0); - rb_define_method(rb_cShape, "has_object_id?", shape_has_object_id, 0); + rb_define_method(rb_cShape, "has_object_id?", shape_has_object_id_p, 0); rb_define_const(rb_cShape, "SHAPE_ROOT", INT2NUM(SHAPE_ROOT)); rb_define_const(rb_cShape, "SHAPE_IVAR", INT2NUM(SHAPE_IVAR)); @@ -127,8 +127,7 @@ bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *v RUBY_FUNC_EXPORTED bool rb_shape_obj_too_complex_p(VALUE obj); bool rb_shape_too_complex_p(rb_shape_t *shape); bool rb_shape_id_too_complex_p(shape_id_t shape_id); -bool rb_shape_has_object_id(rb_shape_t *shape); -bool rb_shape_id_has_object_id(shape_id_t shape_id); +bool rb_shape_has_object_id(shape_id_t shape_id); shape_id_t rb_shape_transition_frozen(VALUE obj); 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); static inline bool rb_shape_obj_has_id(VALUE obj) { - return rb_shape_id_has_object_id(RBASIC_SHAPE_ID(obj)); + return rb_shape_has_object_id(RBASIC_SHAPE_ID(obj)); } // For ext/objspace |