diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:02:56 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:02:56 -0300 |
commit | 60c83ded3080a23bc661ab440c36d0a71b399e2e (patch) | |
tree | 0aa24b14c1215541b52e7885fd2f2c41aa128a06 /lobject.c | |
parent | 07948c3181702c55b7b36069ca519b54371a4ab7 (diff) | |
download | lua-60c83ded3080a23bc661ab440c36d0a71b399e2e.tar.gz lua-60c83ded3080a23bc661ab440c36d0a71b399e2e.tar.bz2 lua-60c83ded3080a23bc661ab440c36d0a71b399e2e.zip |
small optimization for sizes of array constructors
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.94 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.95 2003/01/27 13:00:43 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -30,6 +30,20 @@ | |||
30 | const TObject luaO_nilobject = {LUA_TNIL, {NULL}}; | 30 | const TObject luaO_nilobject = {LUA_TNIL, {NULL}}; |
31 | 31 | ||
32 | 32 | ||
33 | /* | ||
34 | ** converts an integer to a "floating point byte", represented as | ||
35 | ** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm) | ||
36 | */ | ||
37 | int luaO_int2fb (unsigned int x) { | ||
38 | int m = 0; /* mantissa */ | ||
39 | while (x >= (1<<3)) { | ||
40 | x = (x+1) >> 1; | ||
41 | m++; | ||
42 | } | ||
43 | return (m << 3) | cast(int, x); | ||
44 | } | ||
45 | |||
46 | |||
33 | int luaO_log2 (unsigned int x) { | 47 | int luaO_log2 (unsigned int x) { |
34 | static const lu_byte log_8[255] = { | 48 | static const lu_byte log_8[255] = { |
35 | 0, | 49 | 0, |