Roberto Ierusalimschy 24 years ago
parent
commit
b82242d4c4
3 changed files with 11 additions and 8 deletions
  1. 6 1
      lobject.h
  2. 1 3
      lstring.c
  3. 4 4
      ltable.c

+ 6 - 1
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
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -199,6 +199,11 @@ typedef struct Hash {
 #define ismarked(x)	((x)->mark != (x))
 #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)
 ** informations about a call (for debugging)
 */
 */

+ 1 - 3
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)
 ** String table (keeps all strings handled by Lua)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -15,8 +15,6 @@
 #include "lstring.h"
 #include "lstring.h"
 
 
 
 
-#define lmod(s,size)	((int)((s) & ((size)-1)))
-
 
 
 void luaS_init (lua_State *L) {
 void luaS_init (lua_State *L) {
   luaS_resize(L, &G(L)->strt, MINPOWER2);
   luaS_resize(L, &G(L)->strt, MINPOWER2);

+ 4 - 4
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)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -31,9 +31,9 @@
 #define TagDefault LUA_TTABLE
 #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)])
 
 
 
 
 /*
 /*