commit 3dcd04ad610d151afbe8cd92c43e2232e621fbb5
parent faaf7e481fbadc2ef520a96b638dd910f3c9ff14
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 17 Aug 2018 15:53:12 -0300
details
Minor optimizations in 'lvm.c'. (Not exactly optimizations, but more
chances for optimizations.)
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.359 2018/06/18 17:58:21 roberto Exp roberto $
+** $Id: lvm.c $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -621,8 +621,8 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
** otherwise 'floor(q) == trunc(q) - 1'.
*/
lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) {
- if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
- if (unlikely(n == 0))
+ if (unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */
+ if (n == 0)
luaG_runerror(L, "attempt to divide by zero");
return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */
}
@@ -641,14 +641,14 @@ lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) {
** about luaV_div.)
*/
lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
- if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
- if (unlikely(n == 0))
+ if (unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */
+ if (n == 0)
luaG_runerror(L, "attempt to perform 'n%%0'");
return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
}
else {
lua_Integer r = m % n;
- if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */
+ if (r != 0 && (r ^ n) < 0) /* 'm/n' would be non-integer negative? */
r += n; /* correct result for different rounding */
return r;
}