From b4b83cd8d2a7a730ad233443539e72404a2484af Mon Sep 17 00:00:00 2001 From: Lua Team Date: Wed, 18 Apr 2007 00:00:00 -0400 Subject: [PATCH] Very small numbers all collide in the hash function. (Performance problems only) Reported on 18 Apr 2007 --- src/ltable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ltable.c b/src/ltable.c index bc91cac..d4217b2 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -84,8 +84,8 @@ static const Node dummynode_ = { static Node *hashnum (const Table *t, lua_Number n) { unsigned int a[numints]; int i; - n += 1; /* normalize number (avoid -0) */ - lua_assert(sizeof(a) <= sizeof(n)); + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); memcpy(a, &n, sizeof(a)); for (i = 1; i < numints; i++) a[0] += a[i]; return hashmod(t, a[0]); -- 2.11.4.GIT