aboutsummaryrefslogtreecommitdiff
path: root/ltable.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-11-07 10:38:35 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-11-07 10:38:35 -0200
commit7b1fba69b7a887e37e57744309299d134e76e06e (patch)
treee5743e7f4792f065bb9644e827e43eb9a9c03a22 /ltable.h
parent697593d8d5b2e2287919423006c53dcac31d2b70 (diff)
downloadlua-7b1fba69b7a887e37e57744309299d134e76e06e.tar.gz
lua-7b1fba69b7a887e37e57744309299d134e76e06e.tar.bz2
lua-7b1fba69b7a887e37e57744309299d134e76e06e.zip
using 'lastfree == NULL' to signal that table is using the dummy
node for its hash part + new macro 'allocsizenode'
Diffstat (limited to 'ltable.h')
-rw-r--r--ltable.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/ltable.h b/ltable.h
index bad66516..8b80a6df 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp roberto $ 2** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -27,6 +27,14 @@
27#define invalidateTMcache(t) ((t)->flags = 0) 27#define invalidateTMcache(t) ((t)->flags = 0)
28 28
29 29
30/* true when 't' is using 'dummynode' as its hash part */
31#define isdummy(t) ((t)->lastfree == NULL)
32
33
34/* allocated size for hash nodes */
35#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
36
37
30/* returns the key, given the value of a table entry */ 38/* returns the key, given the value of a table entry */
31#define keyfromval(v) \ 39#define keyfromval(v) \
32 (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 40 (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
@@ -51,7 +59,7 @@ LUAI_FUNC int luaH_getn (Table *t);
51 59
52#if defined(LUA_DEBUG) 60#if defined(LUA_DEBUG)
53LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 61LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
54LUAI_FUNC int luaH_isdummy (Node *n); 62LUAI_FUNC int luaH_isdummy (const Table *t);
55#endif 63#endif
56 64
57 65