From 60c83ded3080a23bc661ab440c36d0a71b399e2e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 18 Feb 2003 13:02:56 -0300 Subject: small optimization for sizes of array constructors --- lobject.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lobject.c') diff --git a/lobject.c b/lobject.c index ebe2728f..5c5c1383 100644 --- a/lobject.c +++ b/lobject.c @@ -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, -- cgit v1.2.3-55-g6feb