From b82242d4c493191d543fe5784b4d884e0cba9809 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 26 Jan 2001 13:58:50 -0200 Subject: [PATCH] detail --- lobject.h | 7 ++++++- lstring.c | 4 +--- ltable.c | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lobject.h b/lobject.h index 008b56ab..79600a87 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.87 2001/01/19 13:20:30 roberto Exp roberto $ +** $Id: lobject.h,v 1.88 2001/01/25 16:45:36 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -199,6 +199,11 @@ typedef struct Hash { #define ismarked(x) ((x)->mark != (x)) +/* +** "module" operation (size is always a power of 2) */ +#define lmod(s,size) ((int)((s) & ((size)-1))) + + /* ** informations about a call (for debugging) */ diff --git a/lstring.c b/lstring.c index 6eb236b1..abc293bd 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 1.50 2001/01/11 18:59:20 roberto Exp roberto $ +** $Id: lstring.c,v 1.51 2001/01/19 13:20:30 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -15,8 +15,6 @@ #include "lstring.h" -#define lmod(s,size) ((int)((s) & ((size)-1))) - void luaS_init (lua_State *L) { luaS_resize(L, &G(L)->strt, MINPOWER2); diff --git a/ltable.c b/ltable.c index 6453bf85..5893f629 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 1.68 2001/01/26 13:18:00 roberto Exp roberto $ +** $Id: ltable.c,v 1.69 2001/01/26 14:16:35 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -31,9 +31,9 @@ #define TagDefault LUA_TTABLE -#define hashnum(t,n) (&t->node[(luint32)(lint32)(n)&(t->size-1)]) -#define hashstr(t,str) (&t->node[(str)->u.s.hash&(t->size-1)]) -#define hashpointer(t,p) (&t->node[IntPoint(p)&(t->size-1)]) +#define hashnum(t,n) (&t->node[lmod((luint32)(lint32)(n), t->size)]) +#define hashstr(t,str) (&t->node[lmod((str)->u.s.hash, t->size)]) +#define hashpointer(t,p) (&t->node[lmod(IntPoint(p), t->size)]) /*