diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-11-27 16:05:14 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-11-27 16:05:14 -0200 |
| commit | 8b97b072cd276ece00dc4a9957c0b07cf654fcdc (patch) | |
| tree | 1c73b87437341db55633c8f09c1419dc2e50dcd6 | |
| parent | 5ee63257f9eee2216b6ed06afa93aceac3227fb4 (diff) | |
| download | lua-8b97b072cd276ece00dc4a9957c0b07cf654fcdc.tar.gz lua-8b97b072cd276ece00dc4a9957c0b07cf654fcdc.tar.bz2 lua-8b97b072cd276ece00dc4a9957c0b07cf654fcdc.zip | |
details
| -rw-r--r-- | ltable.c | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -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 | */ |
| 425 | static const TObject *luaH_getany (Table *t, const TObject *key) { | 422 | static 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 | ||
