diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.40 2009/04/17 14:40:13 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.41 2009/08/07 17:53:28 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -18,7 +18,6 @@ | |||
18 | ** Hence even when the load factor reaches 100%, performance remains good. | 18 | ** Hence even when the load factor reaches 100%, performance remains good. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <math.h> | ||
22 | #include <string.h> | 21 | #include <string.h> |
23 | 22 | ||
24 | #define ltable_c | 23 | #define ltable_c |
@@ -82,13 +81,13 @@ static const Node dummynode_ = { | |||
82 | ** hash for lua_Numbers | 81 | ** hash for lua_Numbers |
83 | */ | 82 | */ |
84 | static Node *hashnum (const Table *t, lua_Number n) { | 83 | static Node *hashnum (const Table *t, lua_Number n) { |
85 | unsigned int a[numints]; | ||
86 | int i; | 84 | int i; |
87 | if (luai_numeq(n, 0)) /* avoid problems with -0 */ | 85 | luai_hashnum(i, n); |
88 | return gnode(t, 0); | 86 | if (i < 0) { |
89 | memcpy(a, &n, sizeof(a)); | 87 | i = -i; /* must be a positive value */ |
90 | for (i = 1; i < numints; i++) a[0] += a[i]; | 88 | if (i < 0) i = 0; /* handle INT_MIN */ |
91 | return hashmod(t, a[0]); | 89 | } |
90 | return hashmod(t, i); | ||
92 | } | 91 | } |
93 | 92 | ||
94 | 93 | ||