Skip to content

Commit cec84ff

Browse files
committed
Refactor rb_imemo_fields_new to not assume T_CLASS
1 parent eba082f commit cec84ff

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

imemo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ imemo_fields_new(VALUE klass, size_t capa)
130130
VALUE
131131
rb_imemo_fields_new(VALUE klass, size_t capa)
132132
{
133-
return imemo_fields_new(rb_singleton_class(klass), capa);
133+
return imemo_fields_new(klass, capa);
134134
}
135135

136136
static VALUE
@@ -144,7 +144,7 @@ imemo_fields_new_complex(VALUE klass, size_t capa)
144144
VALUE
145145
rb_imemo_fields_new_complex(VALUE klass, size_t capa)
146146
{
147-
return imemo_fields_new_complex(rb_singleton_class(klass), capa);
147+
return imemo_fields_new_complex(klass, capa);
148148
}
149149

150150
VALUE

internal/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ RCLASS_WRITABLE_ENSURE_FIELDS_OBJ(VALUE obj)
526526
RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
527527
rb_classext_t *ext = RCLASS_EXT_WRITABLE(obj);
528528
if (!ext->fields_obj) {
529-
RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(obj, 1));
529+
RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(rb_singleton_class(obj), 1));
530530
}
531531
return ext->fields_obj;
532532
}

variable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4678,7 +4678,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
46784678
{
46794679
bool existing = true;
46804680
const VALUE original_fields_obj = fields_obj;
4681-
fields_obj = original_fields_obj ? original_fields_obj : rb_imemo_fields_new(klass, 1);
4681+
fields_obj = original_fields_obj ? original_fields_obj : rb_imemo_fields_new(rb_singleton_class(klass), 1);
46824682

46834683
shape_id_t current_shape_id = RBASIC_SHAPE_ID(fields_obj);
46844684
shape_id_t next_shape_id = current_shape_id;
@@ -4699,7 +4699,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
46994699
next_shape_id = rb_shape_transition_add_ivar(fields_obj, id);
47004700
if (UNLIKELY(rb_shape_too_complex_p(next_shape_id))) {
47014701
attr_index_t current_len = RSHAPE_LEN(current_shape_id);
4702-
fields_obj = rb_imemo_fields_new_complex(klass, current_len + 1);
4702+
fields_obj = rb_imemo_fields_new_complex(rb_singleton_class(klass), current_len + 1);
47034703
if (current_len) {
47044704
rb_obj_copy_fields_to_hash_table(original_fields_obj, rb_imemo_fields_complex_tbl(fields_obj));
47054705
RBASIC_SET_SHAPE_ID(fields_obj, next_shape_id);
@@ -4715,7 +4715,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
47154715

47164716
// We allocate a new fields_obj even when concurrency isn't a concern
47174717
// so that we're embedded as long as possible.
4718-
fields_obj = rb_imemo_fields_new(klass, next_capacity);
4718+
fields_obj = rb_imemo_fields_new(rb_singleton_class(klass), next_capacity);
47194719
if (original_fields_obj) {
47204720
MEMCPY(rb_imemo_fields_ptr(fields_obj), rb_imemo_fields_ptr(original_fields_obj), VALUE, RSHAPE_LEN(current_shape_id));
47214721
}

0 commit comments

Comments
 (0)