small optimization for sizes of array constructors

This commit is contained in:
Roberto Ierusalimschy
2003-02-18 13:02:56 -03:00
parent 07948c3181
commit 60c83ded30
5 changed files with 31 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lobject.c,v 1.94 2002/12/04 17:38:31 roberto Exp roberto $
** $Id: lobject.c,v 1.95 2003/01/27 13:00:43 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -30,6 +30,20 @@
const TObject luaO_nilobject = {LUA_TNIL, {NULL}};
/*
** converts an integer to a "floating point byte", represented as
** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm)
*/
int luaO_int2fb (unsigned int x) {
int m = 0; /* mantissa */
while (x >= (1<<3)) {
x = (x+1) >> 1;
m++;
}
return (m << 3) | cast(int, x);
}
int luaO_log2 (unsigned int x) {
static const lu_byte log_8[255] = {
0,