mirror of https://github.com/rusefi/lua.git
small optimization in 'lua_arith' (avoids overhead in the common case
of both arguments being numbers)
This commit is contained in:
parent
a36c8e1718
commit
c1de1fdac6
6
lapi.c
6
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.80 2009/06/17 17:52:57 roberto Exp roberto $
|
** $Id: lapi.c,v 2.81 2009/06/17 18:38:54 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -278,6 +278,10 @@ LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
|
||||||
LUA_API void lua_arith (lua_State *L, int op) {
|
LUA_API void lua_arith (lua_State *L, int op) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, 2);
|
api_checknelems(L, 2);
|
||||||
|
if (ttisnumber(L->top - 2) && ttisnumber(L->top - 1))
|
||||||
|
changenvalue(L->top - 2,
|
||||||
|
luaO_arith(op, nvalue(L->top - 2), nvalue(L->top - 1)));
|
||||||
|
else
|
||||||
luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD);
|
luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD);
|
||||||
L->top--;
|
L->top--;
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
|
|
Loading…
Reference in New Issue