diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-24 12:24:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-24 12:24:42 -0300 |
commit | 5205f073c57ae4b69e90d35c02e3a1a1cca44eb4 (patch) | |
tree | 960dfa533a10a825631e83a391434c0bf02e8ecd /lcode.c | |
parent | 31925e4cc20018b2cf46664febd6347ce4a4b766 (diff) | |
download | lua-5205f073c57ae4b69e90d35c02e3a1a1cca44eb4.tar.gz lua-5205f073c57ae4b69e90d35c02e3a1a1cca44eb4.tar.bz2 lua-5205f073c57ae4b69e90d35c02e3a1a1cca44eb4.zip |
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".
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1298,7 +1298,8 @@ static int validop (int op, TValue *v1, TValue *v2) { | |||
1298 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: | 1298 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
1299 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ | 1299 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
1300 | lua_Integer i; | 1300 | lua_Integer i; |
1301 | return (tointegerns(v1, &i) && tointegerns(v2, &i)); | 1301 | return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && |
1302 | luaV_tointegerns(v2, &i, LUA_FLOORN2I)); | ||
1302 | } | 1303 | } |
1303 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ | 1304 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
1304 | return (nvalue(v2) != 0); | 1305 | return (nvalue(v2) != 0); |