repo.or.cz
/
lua.git
/
commitdiff
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
raw
|
patch
|
inline
|
side by side
(parent:
1ef375b
)
Very small numbers all collide in the hash function. (Performance problems only)
author
Lua Team
<
[email protected]
>
Wed, 18 Apr 2007 04:00:00 +0000
(18
00:00
-0400)
committer
Thomas Harning Jr
<
[email protected]
>
Wed, 12 Sep 2007 02:35:49 +0000
(11 22:35 -0400)
Reported on 18 Apr 2007
src/ltable.c
patch
|
blob
|
blame
|
history
diff --git
a/src/ltable.c
b/src/ltable.c
index
bc91cac
..
d4217b2
100644
(file)
--- 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]);