ruby-changes:54221
From: nobu <ko1@a...>
Date: Wed, 19 Dec 2018 00:11:21 +0900 (JST)
Subject: [ruby-changes:54221] nobu:r66442 (trunk): Expand cross-recursion to a loop
nobu 2018-12-19 00:11:17 +0900 (Wed, 19 Dec 2018) New Revision: 66442 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66442 Log: Expand cross-recursion to a loop Modified files: trunk/vm_method.c Index: vm_method.c =================================================================== --- vm_method.c (revision 66441) +++ vm_method.c (revision 66442) @@ -922,49 +922,36 @@ rb_callable_method_entry_without_refinem https://github.com/ruby/ruby/blob/trunk/vm_method.c#L922 } static const rb_method_entry_t * -refined_method_original_method_entry(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) -{ - VALUE super; - - if (me->def->body.refined.orig_me) { - if (defined_class_ptr) *defined_class_ptr = me->def->body.refined.orig_me->defined_class; - return me->def->body.refined.orig_me; - } - else if (!(super = RCLASS_SUPER(me->owner))) { - return 0; - } - else { - rb_method_entry_t *tmp_me; - tmp_me = method_entry_get(super, me->called_id, defined_class_ptr); - return resolve_refined_method(refinements, tmp_me, defined_class_ptr); - } -} - -static const rb_method_entry_t * resolve_refined_method(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) { - if (me && me->def->type == VM_METHOD_TYPE_REFINED) { + while (me && me->def->type == VM_METHOD_TYPE_REFINED) { VALUE refinement; rb_method_entry_t *tmp_me; + VALUE super; refinement = find_refinement(refinements, me->owner); - if (NIL_P(refinement)) { - return refined_method_original_method_entry(refinements, me, defined_class_ptr); - } - else { + if (!NIL_P(refinement)) { tmp_me = method_entry_get(refinement, me->called_id, defined_class_ptr); if (tmp_me && tmp_me->def->type != VM_METHOD_TYPE_REFINED) { return tmp_me; } - else { - return refined_method_original_method_entry(refinements, me, defined_class_ptr); - } } + + tmp_me = me->def->body.refined.orig_me; + if (tmp_me) { + if (defined_class_ptr) *defined_class_ptr = tmp_me->defined_class; + return tmp_me; + } + + super = RCLASS_SUPER(me->owner); + if (!super) { + return 0; + } + + me = method_entry_get(super, me->called_id, defined_class_ptr); } - else { - return me; - } + return me; } const rb_method_entry_t * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/