From 1936a9e53bac819e3707a47998c9b5fb705c2b7c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 May 1996 11:30:27 -0300 Subject: [PATCH] tables may grow bigger than words. --- hash.c | 49 +++++++++++++++++++++++++------------------------ hash.h | 12 ++++++------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/hash.c b/hash.c index 8e541a1e..58598c7c 100644 --- a/hash.c +++ b/hash.c @@ -3,7 +3,7 @@ ** hash manager for lua */ -char *rcs_hash="$Id: hash.c,v 2.28 1996/02/12 18:32:40 roberto Exp roberto $"; +char *rcs_hash="$Id: hash.c,v 2.29 1996/02/14 18:25:04 roberto Exp roberto $"; #include "mem.h" @@ -29,14 +29,15 @@ static Hash *listhead = NULL; /* hash dimensions values */ -static Word dimensions[] = - {3, 5, 7, 11, 23, 47, 97, 197, 397, 797, 1597, 3203, 6421, - 12853, 25717, 51437, 65521, 0}; /* 65521 == last prime < MAX_WORD */ +static Long dimensions[] = + {3L, 5L, 7L, 11L, 23L, 47L, 97L, 197L, 397L, 797L, 1597L, 3203L, 6421L, + 12853L, 25717L, 51437L, 102811L, 205619L, 411233L, 822433L, + 1644817L, 3289613L, 6579211L, 13158023L, MAX_INT}; -Word luaI_redimension (Word nhash) +int luaI_redimension (int nhash) { - Word i; - for (i=0; dimensions[i]!=0; i++) + int i; + for (i=0; dimensions[i] nhash) return dimensions[i]; @@ -45,7 +46,7 @@ Word luaI_redimension (Word nhash) return 0; /* to avoid warnings */ } -static Word hashindex (Hash *t, Object *ref) /* hash function */ +static int hashindex (Hash *t, Object *ref) /* hash function */ { switch (tag(ref)) { @@ -53,9 +54,9 @@ static Word hashindex (Hash *t, Object *ref) /* hash function */ lua_error ("unexpected type to index table"); return -1; /* UNREACHEABLE */ case LUA_T_NUMBER: - return (((Word)nvalue(ref))%nhash(t)); + return (((int)nvalue(ref))%nhash(t)); case LUA_T_STRING: - return (Word)((tsvalue(ref)->hash)%nhash(t)); /* make it a valid index */ + return (int)((tsvalue(ref)->hash)%nhash(t)); /* make it a valid index */ case LUA_T_FUNCTION: return (((IntPoint)ref->value.tf)%nhash(t)); case LUA_T_CFUNCTION: @@ -82,9 +83,9 @@ int lua_equalObj (Object *t1, Object *t2) } } -static Word present (Hash *t, Object *ref) +static int present (Hash *t, Object *ref) { - Word h = hashindex(t, ref); + int h = hashindex(t, ref); while (tag(ref(node(t, h))) != LUA_T_NIL) { if (lua_equalObj(ref, ref(node(t, h)))) @@ -98,9 +99,9 @@ static Word present (Hash *t, Object *ref) /* ** Alloc a vector node */ -static Node *hashnodecreate (Word nhash) +static Node *hashnodecreate (int nhash) { - Word i; + int i; Node *v = newvector (nhash, Node); for (i=0; i= nhash(t)) { @@ -316,7 +317,7 @@ void lua_next (void) } else { - Word h = present (t, luaI_Address(r)); + int h = present (t, luaI_Address(r)); hashnext(t, h+1); } } diff --git a/hash.h b/hash.h index e2bd2233..d0e26f90 100644 --- a/hash.h +++ b/hash.h @@ -1,7 +1,7 @@ /* ** hash.h ** hash manager for lua -** $Id: hash.h,v 2.10 1996/02/12 18:32:40 roberto Exp roberto $ +** $Id: hash.h,v 2.11 1996/03/08 12:04:04 roberto Exp roberto $ */ #ifndef hash_h @@ -19,16 +19,16 @@ typedef struct node typedef struct Hash { struct Hash *next; - char mark; - Word nhash; - Word nuse; Node *node; + int nhash; + int nuse; + char mark; } Hash; int lua_equalObj (Object *t1, Object *t2); -Word luaI_redimension (Word nhash); -Hash *lua_createarray (Word nhash); +int luaI_redimension (int nhash); +Hash *lua_createarray (int nhash); void lua_hashmark (Hash *h); Long lua_hashcollector (void); Object *lua_hashget (Hash *t, Object *ref);