aboutsummaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/vm_method.c b/vm_method.c
index 0abef8f24b..c343015778 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -806,16 +806,17 @@ prepare_callable_method_entry(VALUE defined_class, ID id, const rb_method_entry_
VM_ASSERT(RB_TYPE_P(defined_class, T_ICLASS) || RB_TYPE_P(defined_class, T_MODULE));
VM_ASSERT(me->defined_class == 0);
- if ((mtbl = RCLASS_CALLABLE_M_TBL(defined_class)) == NULL) {
- mtbl = RCLASS_EXT(defined_class)->callable_m_tbl = rb_id_table_create(0);
- }
+ mtbl = RCLASS_CALLABLE_M_TBL(defined_class);
- if (rb_id_table_lookup(mtbl, id, (VALUE *)&me)) {
+ if (mtbl && rb_id_table_lookup(mtbl, id, (VALUE *)&me)) {
RB_DEBUG_COUNTER_INC(mc_cme_complement_hit);
cme = (rb_callable_method_entry_t *)me;
VM_ASSERT(callable_method_entry_p(cme));
}
else {
+ if (!mtbl) {
+ mtbl = RCLASS_EXT(defined_class)->callable_m_tbl = rb_id_table_create(0);
+ }
cme = rb_method_entry_complement_defined_class(me, me->called_id, defined_class);
rb_id_table_insert(mtbl, id, (VALUE)cme);
VM_ASSERT(callable_method_entry_p(cme));