in hash nodes, keys are stored in separate pieces to avoid wasting
space with alignments
This commit is contained in:
18
ltable.h
18
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);
|
||||
|
||||
Reference in New Issue
Block a user