|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
** $Id: ltable.c,v 2.36 2007/04/10 12:18:17 roberto Exp roberto $ |
|
|
|
** $Id: ltable.c,v 2.37 2007/04/18 19:24:35 roberto Exp roberto $ |
|
|
|
** Lua tables (hash) |
|
|
|
** See Copyright Notice in lua.h |
|
|
|
*/ |
|
|
@ -186,24 +186,6 @@ int luaH_next (lua_State *L, Table *t, StkId key) { |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
static int ceillog2 (unsigned int x) { |
|
|
|
static const lu_byte log_2[256] = { |
|
|
|
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, |
|
|
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, |
|
|
|
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
|
|
|
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
|
|
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, |
|
|
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, |
|
|
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, |
|
|
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 |
|
|
|
}; |
|
|
|
int l = 0; |
|
|
|
x--; |
|
|
|
while (x >= 256) { l += 8; x >>= 8; } |
|
|
|
return l + log_2[x]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int computesizes (int nums[], int *narray) { |
|
|
|
int i; |
|
|
|
int twotoi; /* 2^i */ |
|
|
@ -229,7 +211,7 @@ static int computesizes (int nums[], int *narray) { |
|
|
|
static int countint (const TValue *key, int *nums) { |
|
|
|
int k = arrayindex(key); |
|
|
|
if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ |
|
|
|
nums[ceillog2(k)]++; /* count as such */ |
|
|
|
nums[luaO_ceillog2(k)]++; /* count as such */ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
else |
|
|
@ -295,7 +277,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { |
|
|
|
} |
|
|
|
else { |
|
|
|
int i; |
|
|
|
lsize = ceillog2(size); |
|
|
|
lsize = luaO_ceillog2(size); |
|
|
|
if (lsize > MAXBITS) |
|
|
|
luaG_runerror(L, "table overflow"); |
|
|
|
size = twoto(lsize); |
|
|
|