mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
More precisely iterate over Object instance variables
Shapes provides us with an (almost) exact count of instance variables. We only need to check for Qundef when an IV has been "undefined" Prefer to use ROBJECT_IV_COUNT when iterating IVs
This commit is contained in:
parent
8d20632df8
commit
f0654b1027
Notes:
git
2022-10-16 02:44:40 +09:00
5 changed files with 29 additions and 29 deletions
9
shape.h
9
shape.h
|
@ -125,6 +125,15 @@ bool rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t * value);
|
|||
shape_id_t rb_shape_id(rb_shape_t * shape);
|
||||
MJIT_SYMBOL_EXPORT_END
|
||||
|
||||
static inline uint32_t
|
||||
ROBJECT_IV_COUNT(VALUE obj)
|
||||
{
|
||||
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
||||
uint32_t ivc = rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj))->iv_count;
|
||||
RUBY_ASSERT(ivc <= ROBJECT_NUMIV(obj));
|
||||
return ivc;
|
||||
}
|
||||
|
||||
rb_shape_t * rb_shape_alloc(ID edge_name, rb_shape_t * parent);
|
||||
rb_shape_t * rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue