From a76fa251998ea83679cfad24542cf4c1aa3d6131 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 30 Jan 2008 16:05:23 -0200 Subject: 'ceillog2' now is exported (other modules may need it) --- ltable.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index def5d581..a92b58ca 100644 --- a/ltable.c +++ b/ltable.c @@ -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); -- cgit v1.2.3-55-g6feb