summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-09-26 10:26:40 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-09-30 10:26:38 +0900
commit86427a321997b733bf8ebb6036157c341a52edfc (patch)
tree8b2816538a62b48bf11e66d9be5eb61d631f2807 /vm_method.c
parent6fdd701472af5355562cb2394167b26a4c3a2a97 (diff)
refactor delete METHOD_ENTRY_COMPLEMENTED flag
Because rb_method_definition_t tracks its own complemented_count, we no longer have to check it in rb_method_entry_t side.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2486
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/vm_method.c b/vm_method.c
index 554d209110..241bb30a26 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -142,9 +142,11 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me
}
}
-static void
-rb_method_definition_release(rb_method_definition_t *def, int complemented)
+void
+rb_free_method_entry(const rb_method_entry_t *me)
{
+ rb_method_definition_t *def = me->def;
+
if (def != NULL) {
const int alias_count = def->alias_count;
const int complemented_count = def->complemented_count;
@@ -158,7 +160,7 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented)
xfree(def);
}
else {
- if (complemented) def->complemented_count--;
+ if (def->complemented_count > 0) def->complemented_count--;
else if (def->alias_count > 0) def->alias_count--;
if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d,%d->%d (dec)\n", (void *)def, rb_id2name(def->original_id),
@@ -167,12 +169,6 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented)
}
}
-void
-rb_free_method_entry(const rb_method_entry_t *me)
-{
- rb_method_definition_release(me->def, METHOD_ENTRY_COMPLEMENTED(me));
-}
-
static inline rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr);
extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
@@ -431,7 +427,6 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal
}
me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def);
METHOD_ENTRY_FLAGS_COPY(me, src_me);
- METHOD_ENTRY_COMPLEMENTED_SET(me);
if (!def) {
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
rb_method_definition_set(me, def, &refined);