aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ltable.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/ltable.c b/ltable.c
index c3bce93a..8b55a1f5 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.134 2003/04/28 19:26:16 roberto Exp roberto $ 2** $Id: ltable.c,v 1.135 2003/08/26 12:04:13 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*/
@@ -15,10 +15,7 @@
15** A main invariant of these tables is that, if an element is not 15** A main invariant of these tables is that, if an element is not
16** in its main position (i.e. the `original' position that its hash gives 16** in its main position (i.e. the `original' position that its hash gives
17** to it), then the colliding element is in its own main position. 17** to it), then the colliding element is in its own main position.
18** In other words, there are collisions only when two elements have the 18** Hence even when the load factor reaches 100%, performance remains good.
19** same main position (i.e. the same hash values for that table size).
20** Because of that, the load factor of these tables can be 100% without
21** performance penalties.
22*/ 19*/
23 20
24#include <string.h> 21#include <string.h>
@@ -423,15 +420,14 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
423** generic search function 420** generic search function
424*/ 421*/
425static const TObject *luaH_getany (Table *t, const TObject *key) { 422static const TObject *luaH_getany (Table *t, const TObject *key) {
426 if (ttisnil(key)) return &luaO_nilobject; 423 if (!ttisnil(key)) {
427 else {
428 Node *n = luaH_mainposition(t, key); 424 Node *n = luaH_mainposition(t, key);
429 do { /* check whether `key' is somewhere in the chain */ 425 do { /* check whether `key' is somewhere in the chain */
430 if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */ 426 if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */
431 else n = n->next; 427 else n = n->next;
432 } while (n); 428 } while (n);
433 return &luaO_nilobject;
434 } 429 }
430 return &luaO_nilobject;
435} 431}
436 432
437 433