commit b82242d4c493191d543fe5784b4d884e0cba9809
parent ac390020e91e14f00200ad3df97682b715d3e59b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 26 Jan 2001 13:58:28 -0200
detail
Diffstat:
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git 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
*/
@@ -200,6 +200,11 @@ typedef struct Hash {
/*
+** "module" operation (size is always a power of 2) */
+#define lmod(s,size) ((int)((s) & ((size)-1)))
+
+
+/*
** informations about a call (for debugging)
*/
typedef struct CallInfo {
diff --git 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
@@ -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)])
/*