mirror of https://github.com/rusefi/lua.git
'luai_hashnum' "inlined" into 'hashfloat'
This commit is contained in:
parent
fc083f1138
commit
188192ce9a
13
ltable.c
13
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)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
** Hence even when the load factor reaches 100%, performance remains good.
|
** Hence even when the load factor reaches 100%, performance remains good.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define ltable_c
|
#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;
|
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 (i < 0) {
|
||||||
if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */
|
if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */
|
||||||
i = 0; /* handle INT_MIN */
|
i = 0; /* handle INT_MIN */
|
||||||
|
@ -106,7 +109,7 @@ static Node *mainposition (const Table *t, const TValue *key) {
|
||||||
case LUA_TNUMINT:
|
case LUA_TNUMINT:
|
||||||
return hashint(t, ivalue(key));
|
return hashint(t, ivalue(key));
|
||||||
case LUA_TNUMFLT:
|
case LUA_TNUMFLT:
|
||||||
return hashnum(t, fltvalue(key));
|
return hashfloat(t, fltvalue(key));
|
||||||
case LUA_TSHRSTR:
|
case LUA_TSHRSTR:
|
||||||
return hashstr(t, rawtsvalue(key));
|
return hashstr(t, rawtsvalue(key));
|
||||||
case LUA_TLNGSTR: {
|
case LUA_TLNGSTR: {
|
||||||
|
|
Loading…
Reference in New Issue