mirror of https://github.com/rusefi/lua.git
function 'limittointeger' no needed (now that 'tointeger_aux' handles
integers too)
This commit is contained in:
parent
6b630c0fa0
commit
ddff6ecf30
18
lvm.c
18
lvm.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.202 2014/04/29 20:06:05 roberto Exp roberto $
|
** $Id: lvm.c,v 2.203 2014/04/30 16:50:16 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -126,20 +126,6 @@ int luaV_tointeger_ (const TValue *obj, lua_Integer *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Check whether the limit of a 'for' loop can be safely converted
|
|
||||||
** to an integer (rounding down or up depending on the signal of 'step')
|
|
||||||
*/
|
|
||||||
static int limittointeger (const TValue *n, lua_Integer *p, lua_Integer step) {
|
|
||||||
if (ttisinteger(n)) {
|
|
||||||
*p = ivalue(n);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return tointeger_aux(n, p, (step < 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Convert a number object to a string
|
** Convert a number object to a string
|
||||||
*/
|
*/
|
||||||
|
@ -995,7 +981,7 @@ void luaV_execute (lua_State *L) {
|
||||||
TValue *pstep = ra + 2;
|
TValue *pstep = ra + 2;
|
||||||
lua_Integer ilimit;
|
lua_Integer ilimit;
|
||||||
if (ttisinteger(init) && ttisinteger(pstep) &&
|
if (ttisinteger(init) && ttisinteger(pstep) &&
|
||||||
limittointeger(plimit, &ilimit, ivalue(pstep))) {
|
tointeger_aux(plimit, &ilimit, (ivalue(pstep) < 0))) {
|
||||||
/* all values are integer */
|
/* all values are integer */
|
||||||
setivalue(init, ivalue(init) - ivalue(pstep));
|
setivalue(init, ivalue(init) - ivalue(pstep));
|
||||||
setivalue(plimit, ilimit);
|
setivalue(plimit, ilimit);
|
||||||
|
|
Loading…
Reference in New Issue