1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
卜部昌平 2019-09-26 10:26:40 +09:00
parent 6fdd701472
commit 86427a3219
Notes: git 2019-09-30 10:27:08 +09:00
2 changed files with 5 additions and 12 deletions

View file

@ -66,8 +66,6 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
static inline void
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)

View file

@ -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);