Very small numbers all collide in the hash function. (Performance problems only)
authorLua Team <[email protected]>
Wed, 18 Apr 2007 04:00:00 +0000 (18 00:00 -0400)
committerThomas Harning Jr <[email protected]>
Wed, 12 Sep 2007 02:35:49 +0000 (11 22:35 -0400)
Reported on 18 Apr 2007

src/ltable.c

index bc91cac..d4217b2 100644 (file)
@@ -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]);