зеркало из https://github.com/github/ruby.git
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:
Родитель
6fdd701472
Коммит
86427a3219
2
method.h
2
method.h
|
@ -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_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_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
|
static inline void
|
||||||
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
||||||
|
|
15
vm_method.c
15
vm_method.c
|
@ -142,9 +142,11 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
rb_method_definition_release(rb_method_definition_t *def, int complemented)
|
rb_free_method_entry(const rb_method_entry_t *me)
|
||||||
{
|
{
|
||||||
|
rb_method_definition_t *def = me->def;
|
||||||
|
|
||||||
if (def != NULL) {
|
if (def != NULL) {
|
||||||
const int alias_count = def->alias_count;
|
const int alias_count = def->alias_count;
|
||||||
const int complemented_count = def->complemented_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);
|
xfree(def);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (complemented) def->complemented_count--;
|
if (def->complemented_count > 0) def->complemented_count--;
|
||||||
else if (def->alias_count > 0) def->alias_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),
|
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);
|
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);
|
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);
|
me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def);
|
||||||
METHOD_ENTRY_FLAGS_COPY(me, src_me);
|
METHOD_ENTRY_FLAGS_COPY(me, src_me);
|
||||||
METHOD_ENTRY_COMPLEMENTED_SET(me);
|
|
||||||
if (!def) {
|
if (!def) {
|
||||||
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
|
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
|
||||||
rb_method_definition_set(me, def, &refined);
|
rb_method_definition_set(me, def, &refined);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче