aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-04-10 09:18:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-04-10 09:18:17 -0300
commit94d40f3980d4f13ed33d1c23fcc8c7aafbd7be59 (patch)
treefc38e115dc56be07d1fe2edfc4b6fc35b9d9847b /ltable.c
parent585b81f91eeff445f77de7276b23c8b8df22e8c5 (diff)
downloadlua-94d40f3980d4f13ed33d1c23fcc8c7aafbd7be59.tar.gz
lua-94d40f3980d4f13ed33d1c23fcc8c7aafbd7be59.tar.bz2
lua-94d40f3980d4f13ed33d1c23fcc8c7aafbd7be59.zip
luaO_log2 can be private to ltable.c
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/ltable.c b/ltable.c
index 722e1de3..1b3bc540 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.34 2006/08/07 19:14:30 roberto Exp roberto $ 2** $Id: ltable.c,v 2.35 2006/09/11 14:07:24 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -186,6 +186,24 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
186*/ 186*/
187 187
188 188
189static int ceillog2 (unsigned int x) {
190 static const lu_byte log_2[256] = {
191 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,
192 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,
193 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,
194 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,
195 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,
196 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,
197 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,
198 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
199 };
200 int l = 0;
201 x--;
202 while (x >= 256) { l += 8; x >>= 8; }
203 return l + log_2[x];
204}
205
206
189static int computesizes (int nums[], int *narray) { 207static int computesizes (int nums[], int *narray) {
190 int i; 208 int i;
191 int twotoi; /* 2^i */ 209 int twotoi; /* 2^i */