diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-02-03 17:38:19 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-02-03 19:59:35 +0900 |
commit | 71c746379d5872e250d90ae45c585760afaf9516 (patch) | |
tree | 4b08f3595accfc3a0f58a422d10a1dffcb8bc0ec /vm_method.c | |
parent | 8df1881c8fc9c173963e8f7d0d078e8d56640903 (diff) | |
download | ruby-71c746379d5872e250d90ae45c585760afaf9516.tar.gz |
Make alias for aliased original method
Chaining aliased methods increases searching cost linearly.
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c index 4833ff692c..7218faa5c9 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1932,11 +1932,17 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) } } - if (orig_me->def->type == VM_METHOD_TYPE_ZSUPER) { + switch (orig_me->def->type) { + case VM_METHOD_TYPE_ZSUPER: klass = RCLASS_SUPER(klass); original_name = orig_me->def->original_id; visi = METHOD_ENTRY_VISI(orig_me); goto again; + case VM_METHOD_TYPE_ALIAS: + orig_me = orig_me->def->body.alias.original_me; + VM_ASSERT(orig_me->def->type != VM_METHOD_TYPE_ALIAS); + break; + default: break; } if (visi == METHOD_VISI_UNDEF) visi = METHOD_ENTRY_VISI(orig_me); |