From 5205f073c57ae4b69e90d35c02e3a1a1cca44eb4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 24 Feb 2021 12:24:42 -0300 Subject: Don't use tointegerns when luaV_tointegerns will do Some places don't need the "fast path" macro tointegerns, either because speed is not essential (lcode.c) or because the value is not supposed to be an integer already (luaV_equalobj and luaG_tointerror). Moreover, luaV_equalobj should always use F2Ieq, even if Lua is compiled to "round to floor". --- lcode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 31f23f47..80d975cb 100644 --- a/lcode.c +++ b/lcode.c @@ -1298,7 +1298,8 @@ static int validop (int op, TValue *v1, TValue *v2) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ lua_Integer i; - return (tointegerns(v1, &i) && tointegerns(v2, &i)); + return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && + luaV_tointegerns(v2, &i, LUA_FLOORN2I)); } case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ return (nvalue(v2) != 0); -- cgit v1.2.3-55-g6feb