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?= Date: Fri, 12 Jun 2020 13:45:01 +0900 Subject: [PATCH] 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. --- compile.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/compile.c b/compile.c index 8982ce473a..bb9cdc0873 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 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 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) {