diff options
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 32 |
1 files changed, 4 insertions, 28 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 2.1 2003/12/10 12:13:36 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.2 2004/03/26 14:02:41 roberto Exp roberto $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <string.h> | 21 | #include <string.h> |
| 22 | 22 | ||
| 23 | #define ltable_c | 23 | #define ltable_c |
| 24 | #define LUA_CORE | ||
| 24 | 25 | ||
| 25 | #include "lua.h" | 26 | #include "lua.h" |
| 26 | 27 | ||
| @@ -36,19 +37,14 @@ | |||
| 36 | /* | 37 | /* |
| 37 | ** max size of array part is 2^MAXBITS | 38 | ** max size of array part is 2^MAXBITS |
| 38 | */ | 39 | */ |
| 39 | #if BITS_INT > 26 | 40 | #if LUA_BITSINT > 26 |
| 40 | #define MAXBITS 24 | 41 | #define MAXBITS 24 |
| 41 | #else | 42 | #else |
| 42 | #define MAXBITS (BITS_INT-2) | 43 | #define MAXBITS (LUA_BITSINT-2) |
| 43 | #endif | 44 | #endif |
| 44 | 45 | ||
| 45 | #define MAXASIZE (1 << MAXBITS) | 46 | #define MAXASIZE (1 << MAXBITS) |
| 46 | 47 | ||
| 47 | /* function to convert a lua_Number to int (with any rounding method) */ | ||
| 48 | #ifndef lua_number2int | ||
| 49 | #define lua_number2int(i,n) ((i)=(int)(n)) | ||
| 50 | #endif | ||
| 51 | |||
| 52 | 48 | ||
| 53 | #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) | 49 | #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) |
| 54 | 50 | ||
| @@ -349,26 +345,6 @@ void luaH_free (lua_State *L, Table *t) { | |||
| 349 | } | 345 | } |
| 350 | 346 | ||
| 351 | 347 | ||
| 352 | #if 0 | ||
| 353 | /* | ||
| 354 | ** try to remove an element from a hash table; cannot move any element | ||
| 355 | ** (because gc can call `remove' during a table traversal) | ||
| 356 | */ | ||
| 357 | void luaH_remove (Table *t, Node *e) { | ||
| 358 | Node *mp = luaH_mainposition(t, gkey(e)); | ||
| 359 | if (e != mp) { /* element not in its main position? */ | ||
| 360 | while (mp->next != e) mp = mp->next; /* find previous */ | ||
| 361 | mp->next = e->next; /* remove `e' from its list */ | ||
| 362 | } | ||
| 363 | else { | ||
| 364 | if (e->next != NULL) ?? | ||
| 365 | } | ||
| 366 | lua_assert(ttisnil(gval(node))); | ||
| 367 | setnilvalue(gkey(e)); /* clear node `e' */ | ||
| 368 | e->next = NULL; | ||
| 369 | } | ||
| 370 | #endif | ||
| 371 | |||
| 372 | 348 | ||
| 373 | /* | 349 | /* |
| 374 | ** inserts a new key into a hash table; first, check whether key's main | 350 | ** inserts a new key into a hash table; first, check whether key's main |
