aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-06-18 13:36:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-06-18 13:36:40 -0300
commitc1de1fdac6a7873f8ae016785f364c5ae10abb1e (patch)
treec35fd558daeb517f18252707cba962492cb3b78d /lapi.c
parenta36c8e1718fd32ea99e29797e5124600a16ccc03 (diff)
downloadlua-c1de1fdac6a7873f8ae016785f364c5ae10abb1e.tar.gz
lua-c1de1fdac6a7873f8ae016785f364c5ae10abb1e.tar.bz2
lua-c1de1fdac6a7873f8ae016785f364c5ae10abb1e.zip
small optimization in 'lua_arith' (avoids overhead in the common case
of both arguments being numbers)
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index 137b4ea9..f6e8b034 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.80 2009/06/17 17:52:57 roberto Exp roberto $ 2** $Id: lapi.c,v 2.81 2009/06/17 18:38:54 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -278,7 +278,11 @@ LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
278LUA_API void lua_arith (lua_State *L, int op) { 278LUA_API void lua_arith (lua_State *L, int op) {
279 lua_lock(L); 279 lua_lock(L);
280 api_checknelems(L, 2); 280 api_checknelems(L, 2);
281 luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD); 281 if (ttisnumber(L->top - 2) && ttisnumber(L->top - 1))
282 changenvalue(L->top - 2,
283 luaO_arith(op, nvalue(L->top - 2), nvalue(L->top - 1)));
284 else
285 luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD);
282 L->top--; 286 L->top--;
283 lua_unlock(L); 287 lua_unlock(L);
284} 288}