misc/liblua/ltable.c
changeset 10017 de822cd3df3a
parent 3697 d5b30d6373fc
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    37 
    37 
    38 /*
    38 /*
    39 ** max size of array part is 2^MAXBITS
    39 ** max size of array part is 2^MAXBITS
    40 */
    40 */
    41 #if LUAI_BITSINT > 26
    41 #if LUAI_BITSINT > 26
    42 #define MAXBITS		26
    42 #define MAXBITS     26
    43 #else
    43 #else
    44 #define MAXBITS		(LUAI_BITSINT-2)
    44 #define MAXBITS     (LUAI_BITSINT-2)
    45 #endif
    45 #endif
    46 
    46 
    47 #define MAXASIZE	(1 << MAXBITS)
    47 #define MAXASIZE    (1 << MAXBITS)
    48 
    48 
    49 
    49 
    50 #define hashpow2(t,n)      (gnode(t, lmod((n), sizenode(t))))
    50 #define hashpow2(t,n)      (gnode(t, lmod((n), sizenode(t))))
    51 
    51 
    52 #define hashstr(t,str)  hashpow2(t, (str)->tsv.hash)
    52 #define hashstr(t,str)  hashpow2(t, (str)->tsv.hash)
    55 
    55 
    56 /*
    56 /*
    57 ** for some types, it is better to avoid modulus by power of 2, as
    57 ** for some types, it is better to avoid modulus by power of 2, as
    58 ** they tend to have many 2 factors.
    58 ** they tend to have many 2 factors.
    59 */
    59 */
    60 #define hashmod(t,n)	(gnode(t, ((n) % ((sizenode(t)-1)|1))))
    60 #define hashmod(t,n)    (gnode(t, ((n) % ((sizenode(t)-1)|1))))
    61 
    61 
    62 
    62 
    63 #define hashpointer(t,p)	hashmod(t, IntPoint(p))
    63 #define hashpointer(t,p)    hashmod(t, IntPoint(p))
    64 
    64 
    65 
    65 
    66 /*
    66 /*
    67 ** number of ints inside a lua_Number
    67 ** number of ints inside a lua_Number
    68 */
    68 */
    69 #define numints		cast_int(sizeof(lua_Number)/sizeof(int))
    69 #define numints     cast_int(sizeof(lua_Number)/sizeof(int))
    70 
    70 
    71 
    71 
    72 
    72 
    73 #define dummynode		(&dummynode_)
    73 #define dummynode       (&dummynode_)
    74 
    74 
    75 static const Node dummynode_ = {
    75 static const Node dummynode_ = {
    76   {{NULL}, LUA_TNIL},  /* value */
    76   {{NULL}, LUA_TNIL},  /* value */
    77   {{{NULL}, LUA_TNIL, NULL}}  /* key */
    77   {{{NULL}, LUA_TNIL, NULL}}  /* key */
    78 };
    78 };