summaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-12 11:21:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-12 11:21:44 -0300
commit73ec04fcf3e3f7017786fbaf0a83291b22bec5c4 (patch)
treeb2870a1e832fa3e013b67209592db32b611f8e5f /lobject.h
parentd13a3fb070fd0ec9ec3b85f88e0fcd914aa666d3 (diff)
downloadlua-github-73ec04fcf3e3f7017786fbaf0a83291b22bec5c4.tar.gz
no more 'DEADKEY'. Table traversals do not need to consider dead keys;
if the key is dead, it cannot be given to 'next'. Instead, we now use a 'table' tag without the collectable bit, which makes it a unique tag good enough to reserve space.
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/lobject.h b/lobject.h
index 97afa143..e245f306 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.121 2017/06/01 20:24:05 roberto Exp roberto $
+** $Id: lobject.h,v 2.122 2017/06/09 16:48:44 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -21,10 +21,9 @@
*/
#define LUA_TUPVAL LUA_NUMTAGS /* upvalues */
#define LUA_TPROTO (LUA_NUMTAGS+1) /* function prototypes */
-#define LUA_TDEADKEY (LUA_NUMTAGS+2) /* removed keys in tables */
/*
-** number of all possible tags (including LUA_TNONE but excluding DEADKEY)
+** number of all possible tags (including LUA_TNONE)
*/
#define LUA_TOTALTAGS (LUA_TPROTO + 2)
@@ -559,14 +558,7 @@ typedef struct Table {
#define keyisshrstr(node) (keytt(node) == ctb(LUA_TSHRSTR))
#define keystrval(node) (gco2ts(keyval(node).gc))
-#define keyisdead(node) (keytt(node) == LUA_TDEADKEY)
-
#define setnilkey(node) (keytt(node) = LUA_TNIL)
-#define setdeadkey(node) (keytt(node) = LUA_TDEADKEY)
-
-/* a dead value may get the 'gc' field, but cannot access its contents */
-#define deadkey(n) \
- check_exp(keytt(n) == LUA_TDEADKEY, cast(void *, keyval(n).gc))
#define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE)
@@ -574,6 +566,16 @@ typedef struct Table {
#define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL)
+/*
+** Use a "nil table" to mark dead keys in a table. Those keys serve
+** only to keep space for removed entries, which may still be part of
+** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE
+** set, so these values are considered not collectable and are different
+** from any valid value.
+*/
+#define setdeadkey(n) (keytt(n) = LUA_TTABLE, gckey(n) = NULL)
+
+
/*
** 'module' operation for hashing (size is always a power of 2)