ruby-changes:61995
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:50 +0900 (JST)
Subject: [ruby-changes:61995] a8d992ac00 (master): compile_call: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=a8d992ac00 From a8d992ac000d4cc8f8fe691d22c45e5b8db95f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Fri, 12 Jun 2020 13:45:01 +0900 Subject: compile_call: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. diff --git a/compile.c b/compile.c index 8982ce4..bb9cdc0 100644 --- a/compile.c +++ b/compile.c @@ -7290,16 +7290,10 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co https://github.com/ruby/ruby/blob/trunk/compile.c#L7290 if (bf == NULL) { if (strcmp("cstmt!", builtin_func) == 0 || strcmp("cexpr!", builtin_func) == 0) { - inlinec:; - int inline_index = GET_VM()->builtin_inline_index++; - snprintf(inline_func, 0x20, "_bi%d", inline_index); - builtin_func = inline_func; - args_node = NULL; - goto retry; + // ok } else if (strcmp("cconst!", builtin_func) == 0) { cconst = true; - goto inlinec; } else if (strcmp("cinit!", builtin_func) == 0) { // ignore @@ -7311,14 +7305,19 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co https://github.com/ruby/ruby/blob/trunk/compile.c#L7305 iseq->body->builtin_inline_p = true; return COMPILE_OK; } - - if (1) { + else if (1) { rb_bug("can't find builtin function:%s", builtin_func); } else { COMPILE_ERROR(ERROR_ARGS "can't find builtin function:%s", builtin_func); + return COMPILE_NG; } - return COMPILE_NG; + + int inline_index = GET_VM()->builtin_inline_index++; + snprintf(inline_func, 0x20, "_bi%d", inline_index); + builtin_func = inline_func; + args_node = NULL; + goto retry; } if (cconst) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/