From d015f1fc02e03864b0ed3ad668a6e0660417a718 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 26 Nov 1999 16:59:20 -0200 Subject: table sizes don't need to be primes; power of 2 gives the same performance. --- lobject.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index ea397620..d286095f 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.36 1999/11/10 15:39:35 roberto Exp roberto $ +** $Id: lobject.h,v 1.37 1999/11/22 13:12:07 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -45,7 +45,8 @@ typedef unsigned char Byte; /* unsigned 8 bits */ /* convertion of pointer to int (for hashing only) */ -#define IntPoint(L, p) ((unsigned int)(p)) +/* (the shift removes bits that are usually 0 because of alignment) */ +#define IntPoint(L, p) (((unsigned int)(p)) >> 3) /* @@ -194,9 +195,11 @@ typedef struct Hash { extern const char *const luaO_typenames[]; - #define luaO_typename(L, o) luaO_typenames[-ttype(o)] +#define MINPOWER2 4 /* minimum size for "growing" vectors */ + +unsigned long luaO_power2 (unsigned long n); extern const TObject luaO_nilobject; -- cgit v1.2.3-55-g6feb