From 188192ce9a3d5d111d2c1ceed41d27ab6a5d57dc Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 29 May 2013 11:05:03 -0300 Subject: [PATCH] 'luai_hashnum' "inlined" into 'hashfloat' --- ltable.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ltable.c b/ltable.c index ae92cbd9..80d3ff3e 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.75 2013/04/29 17:12:50 roberto Exp roberto $ +** $Id: ltable.c,v 2.76 2013/05/27 12:43:37 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -18,6 +18,8 @@ ** Hence even when the load factor reaches 100%, performance remains good. */ +#include +#include #include #define ltable_c @@ -82,11 +84,12 @@ static const Node dummynode_ = { /* -** hash for lua_Numbers +** hash for floating-point numbers */ -static Node *hashnum (const Table *t, lua_Number n) { +static Node *hashfloat (const Table *t, lua_Number n) { int i; - luai_hashnum(i, n); + n = l_mathop(frexp)(n, &i) * cast_num(INT_MAX - DBL_MAX_EXP); + i += cast_int(n); if (i < 0) { if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */ i = 0; /* handle INT_MIN */ @@ -106,7 +109,7 @@ static Node *mainposition (const Table *t, const TValue *key) { case LUA_TNUMINT: return hashint(t, ivalue(key)); case LUA_TNUMFLT: - return hashnum(t, fltvalue(key)); + return hashfloat(t, fltvalue(key)); case LUA_TSHRSTR: return hashstr(t, rawtsvalue(key)); case LUA_TLNGSTR: {