Skip to content

Commit 39257a3

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

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
@@ -322,17 +322,17 @@ ROBJECT_FIELDS_HASH(VALUE obj)
322322
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
323323
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
324324

325-
return (st_table *)ROBJECT(obj)->as.heap.fields;
325+
return ROBJECT(obj)->as.hash;
326326
}
327327

328328
static inline void
329-
ROBJECT_SET_FIELDS_HASH(VALUE obj, const st_table *tbl)
329+
ROBJECT_SET_FIELDS_HASH(VALUE obj, st_table *tbl)
330330
{
331331
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
332332
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
333333
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
334334

335-
ROBJECT(obj)->as.heap.fields = (VALUE *)tbl;
335+
ROBJECT(obj)->as.hash = tbl;
336336
}
337337

338338
static inline uint32_t

0 commit comments

Comments
 (0)