From 4846f7e3bb1397142ab0de808ae59c08db9832a6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 Jul 2019 15:44:37 -0300 Subject: Micro optimization in OP_RETURN and OP_TAILCALL Many functions are vararg but create no upvalues, so it is better to separate the tests for these two kinds of "extra work". --- lcode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index a0d7757a..e57ad284 100644 --- a/lcode.c +++ b/lcode.c @@ -1745,10 +1745,10 @@ void luaK_finish (FuncState *fs) { SET_OPCODE(*pc, OP_RETURN); } /* FALLTHROUGH */ case OP_RETURN: case OP_TAILCALL: { - if (fs->needclose || p->is_vararg) { - SETARG_C(*pc, p->is_vararg ? p->numparams + 1 : 0); - SETARG_k(*pc, 1); /* signal that there is extra work */ - } + if (fs->needclose) + SETARG_k(*pc, 1); /* signal that it needs to close */ + if (p->is_vararg) + SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */ break; } case OP_JMP: { -- cgit v1.2.3-55-g6feb