From b6f87491afe32140563fe3c546b8812c28a63410 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Jun 2017 13:48:44 -0300 Subject: in hash nodes, keys are stored in separate pieces to avoid wasting space with alignments --- ltable.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'ltable.h') diff --git a/ltable.h b/ltable.h index ee22cf62..88f90636 100644 --- a/ltable.h +++ b/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp roberto $ +** $Id: ltable.h,v 2.24 2017/05/19 12:48:15 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -12,18 +12,9 @@ #define gnode(t,i) (&(t)->node[i]) #define gval(n) (&(n)->i_val) -#define gnext(n) ((n)->i_key.nk.next) +#define gnext(n) ((n)->u.next) -/* 'const' to avoid wrong writings that can mess up field 'next' */ -#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) - -/* -** writable version of 'gkey'; allows updates to individual fields, -** but not to the whole (which has incompatible type) -*/ -#define wgkey(n) (&(n)->i_key.nk) - #define invalidateTMcache(t) ((t)->flags = 0) @@ -35,9 +26,8 @@ #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)))) +/* returns the Node, given the value of a table entry */ +#define nodefromval(v) cast(Node *, (v)) LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); -- cgit v1.2.3-55-g6feb