ruby-changes:46699
From: nobu <ko1@a...>
Date: Sat, 20 May 2017 19:27:35 +0900 (JST)
Subject: [ruby-changes:46699] nobu:r58814 (trunk): compile.c: binary logop check
nobu 2017-05-20 19:27:27 +0900 (Sat, 20 May 2017) New Revision: 58814 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58814 Log: compile.c: binary logop check * compile.c (compile_branch_condition): turn recursion at binary logical operator into loop by goto, and check the result of RHS of NODE_OR. Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 58813) +++ compile.c (revision 58814) @@ -2902,6 +2902,7 @@ static int https://github.com/ruby/ruby/blob/trunk/compile.c#L2902 compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond, LABEL *then_label, LABEL *else_label) { + again: switch (nd_type(cond)) { case NODE_AND: { @@ -2909,9 +2910,8 @@ compile_branch_condition(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L2910 CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label, else_label)); ADD_LABEL(ret, label); - CHECK(compile_branch_condition(iseq, ret, cond->nd_2nd, then_label, - else_label)); - break; + cond = cond->nd_2nd; + goto again; } case NODE_OR: { @@ -2919,9 +2919,8 @@ compile_branch_condition(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L2919 CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label, label)); ADD_LABEL(ret, label); - compile_branch_condition(iseq, ret, cond->nd_2nd, then_label, - else_label); - break; + cond = cond->nd_2nd; + goto again; } case NODE_LIT: /* NODE_LIT is always true */ case NODE_TRUE: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/