Skip to content

Commit aea2428

Browse files
committed
Add field in RObject for too complex hash case
Avoids the need to cast fields into a st_table.
1 parent 1c39cc8 commit aea2428

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

include/ruby/internal/core/robject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ struct RObject {
9999
VALUE *fields;
100100
} heap;
101101

102+
/* When an object is too complex, it uses a st_table to store instance
103+
* variable name to value mappings.
104+
*/
105+
st_table *hash;
106+
102107
/* Embedded instance variables. When an object is small enough, it
103108
* uses this area to store the instance variables.
104109
*

shape.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,17 @@ ROBJECT_FIELDS_HASH(VALUE obj)
364364
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
365365
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
366366

367-
return (st_table *)ROBJECT(obj)->as.heap.fields;
367+
return ROBJECT(obj)->as.hash;
368368
}
369369

370370
static inline void
371-
ROBJECT_SET_FIELDS_HASH(VALUE obj, const st_table *tbl)
371+
ROBJECT_SET_FIELDS_HASH(VALUE obj, st_table *tbl)
372372
{
373373
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
374374
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
375375
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
376376

377-
ROBJECT(obj)->as.heap.fields = (VALUE *)tbl;
377+
ROBJECT(obj)->as.hash = tbl;
378378
}
379379

380380
static inline uint32_t

0 commit comments

Comments
 (0)