diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-04-10 09:18:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-04-10 09:18:17 -0300 |
commit | 94d40f3980d4f13ed33d1c23fcc8c7aafbd7be59 (patch) | |
tree | fc38e115dc56be07d1fe2edfc4b6fc35b9d9847b /ltable.c | |
parent | 585b81f91eeff445f77de7276b23c8b8df22e8c5 (diff) | |
download | lua-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.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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 | ||
189 | static 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 | |||
189 | static int computesizes (int nums[], int *narray) { | 207 | static int computesizes (int nums[], int *narray) { |
190 | int i; | 208 | int i; |
191 | int twotoi; /* 2^i */ | 209 | int twotoi; /* 2^i */ |