aboutsummaryrefslogtreecommitdiff
path: root/lvm.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-01-05 14:07:21 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-01-05 14:07:21 -0200
commit1a44e822009752513ce895b9eabc51a4ee4a195a (patch)
treedc8c1dc1ca01601335e447d3d627b4354247a31d /lvm.h
parenta272fa66f0c149689e2a2c896434967b7248a0eb (diff)
downloadlua-1a44e822009752513ce895b9eabc51a4ee4a195a.tar.gz
lua-1a44e822009752513ce895b9eabc51a4ee4a195a.tar.bz2
lua-1a44e822009752513ce895b9eabc51a4ee4a195a.zip
'luaV_fastget' only treats the real fast case (table with a non-nil
value at given key, so that it does not need to check metamethods)
Diffstat (limited to 'lvm.h')
-rw-r--r--lvm.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/lvm.h b/lvm.h
index b65061ac..f6f99c7a 100644
--- a/lvm.h
+++ b/lvm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.h,v 2.38 2015/08/03 20:40:26 roberto Exp roberto $ 2** $Id: lvm.h,v 2.39 2015/09/09 13:44:07 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -49,25 +49,24 @@
49 49
50 50
51/* 51/*
52** fast track for 'gettable': 1 means 'aux' points to resulted value; 52** fast track for 'gettable': if 't' is a table and 't[k]' is not nil,
53** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is 53** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise,
54** the raw get function to use. 54** return 0 (meaning it will have to check metamethod) with 'slot'
55** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise).
56** 'f' is the raw get function to use.
55*/ 57*/
56#define luaV_fastget(L,t,k,aux,f) \ 58#define luaV_fastget(L,t,k,slot,f) \
57 (!ttistable(t) \ 59 (!ttistable(t) \
58 ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ 60 ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \
59 : (aux = f(hvalue(t), k), /* else, do raw access */ \ 61 : (slot = f(hvalue(t), k), /* else, do raw access */ \
60 !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ 62 !ttisnil(slot))) /* result not nil? */
61 : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\
62 aux != NULL ? 0 /* has metamethod? must call it */ \
63 : (aux = luaO_nilobject, 1)))) /* else, final result is nil */
64 63
65/* 64/*
66** standard implementation for 'gettable' 65** standard implementation for 'gettable'
67*/ 66*/
68#define luaV_gettable(L,t,k,v) { const TValue *aux; \ 67#define luaV_gettable(L,t,k,v) { const TValue *slot; \
69 if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ 68 if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
70 else luaV_finishget(L,t,k,v,aux); } 69 else luaV_finishget(L,t,k,v,slot); }
71 70
72 71
73/* 72/*
@@ -100,9 +99,9 @@ LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
100LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 99LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
101LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); 100LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode);
102LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 101LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
103 StkId val, const TValue *tm); 102 StkId val, const TValue *slot);
104LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 103LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
105 StkId val, const TValue *oldval); 104 StkId val, const TValue *slot);
106LUAI_FUNC void luaV_finishOp (lua_State *L); 105LUAI_FUNC void luaV_finishOp (lua_State *L);
107LUAI_FUNC void luaV_execute (lua_State *L); 106LUAI_FUNC void luaV_execute (lua_State *L);
108LUAI_FUNC void luaV_concat (lua_State *L, int total); 107LUAI_FUNC void luaV_concat (lua_State *L, int total);