From 7b1fba69b7a887e37e57744309299d134e76e06e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 7 Nov 2016 10:38:35 -0200 Subject: using 'lastfree == NULL' to signal that table is using the dummy node for its hash part + new macro 'allocsizenode' --- ltable.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ltable.h') diff --git a/ltable.h b/ltable.h index bad66516..8b80a6df 100644 --- a/ltable.h +++ b/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp roberto $ +** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -27,6 +27,14 @@ #define invalidateTMcache(t) ((t)->flags = 0) +/* true when 't' is using 'dummynode' as its hash part */ +#define isdummy(t) ((t)->lastfree == NULL) + + +/* allocated size for hash nodes */ +#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) + + /* returns the key, given the value of a table entry */ #define keyfromval(v) \ (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) @@ -51,7 +59,7 @@ LUAI_FUNC int luaH_getn (Table *t); #if defined(LUA_DEBUG) LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (Node *n); +LUAI_FUNC int luaH_isdummy (const Table *t); #endif -- cgit v1.2.3-55-g6feb