diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 10:36:14 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 10:36:14 -0300 |
| commit | ca41b43f53562e64abe433d6346d174c92548603 (patch) | |
| tree | 03f7a99f76359fc1e0bbc45fc13e579ff2aafabb /ltable.c | |
| parent | 3511e186cde4b78f268d17199d0f46fb3eaa9638 (diff) | |
| download | lua-ca41b43f53562e64abe433d6346d174c92548603.tar.gz lua-ca41b43f53562e64abe433d6346d174c92548603.tar.bz2 lua-ca41b43f53562e64abe433d6346d174c92548603.zip | |
type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 22 |
1 files changed, 11 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 2.90 2014/06/18 22:59:29 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.91 2014/06/26 16:17:35 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 | */ |
| @@ -52,7 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) | 53 | #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) |
| 54 | 54 | ||
| 55 | #define hashstr(t,str) hashpow2(t, (str)->tsv.hash) | 55 | #define hashstr(t,str) hashpow2(t, (str)->hash) |
| 56 | #define hashboolean(t,p) hashpow2(t, p) | 56 | #define hashboolean(t,p) hashpow2(t, p) |
| 57 | #define hashint(t,i) hashpow2(t, i) | 57 | #define hashint(t,i) hashpow2(t, i) |
| 58 | 58 | ||
| @@ -116,14 +116,14 @@ static Node *mainposition (const Table *t, const TValue *key) { | |||
| 116 | case LUA_TNUMFLT: | 116 | case LUA_TNUMFLT: |
| 117 | return hashfloat(t, fltvalue(key)); | 117 | return hashfloat(t, fltvalue(key)); |
| 118 | case LUA_TSHRSTR: | 118 | case LUA_TSHRSTR: |
| 119 | return hashstr(t, rawtsvalue(key)); | 119 | return hashstr(t, tsvalue(key)); |
| 120 | case LUA_TLNGSTR: { | 120 | case LUA_TLNGSTR: { |
| 121 | TString *s = rawtsvalue(key); | 121 | TString *s = tsvalue(key); |
| 122 | if (s->tsv.extra == 0) { /* no hash? */ | 122 | if (s->extra == 0) { /* no hash? */ |
| 123 | s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash); | 123 | s->hash = luaS_hash(getstr(s), s->len, s->hash); |
| 124 | s->tsv.extra = 1; /* now it has its hash */ | 124 | s->extra = 1; /* now it has its hash */ |
| 125 | } | 125 | } |
| 126 | return hashstr(t, rawtsvalue(key)); | 126 | return hashstr(t, tsvalue(key)); |
| 127 | } | 127 | } |
| 128 | case LUA_TBOOLEAN: | 128 | case LUA_TBOOLEAN: |
| 129 | return hashboolean(t, bvalue(key)); | 129 | return hashboolean(t, bvalue(key)); |
| @@ -501,9 +501,9 @@ const TValue *luaH_getint (Table *t, lua_Integer key) { | |||
| 501 | */ | 501 | */ |
| 502 | const TValue *luaH_getstr (Table *t, TString *key) { | 502 | const TValue *luaH_getstr (Table *t, TString *key) { |
| 503 | Node *n = hashstr(t, key); | 503 | Node *n = hashstr(t, key); |
| 504 | lua_assert(key->tsv.tt == LUA_TSHRSTR); | 504 | lua_assert(key->tt == LUA_TSHRSTR); |
| 505 | for (;;) { /* check whether `key' is somewhere in the chain */ | 505 | for (;;) { /* check whether `key' is somewhere in the chain */ |
| 506 | if (ttisshrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)), key)) | 506 | if (ttisshrstring(gkey(n)) && eqshrstr(tsvalue(gkey(n)), key)) |
| 507 | return gval(n); /* that's it */ | 507 | return gval(n); /* that's it */ |
| 508 | else { | 508 | else { |
| 509 | int nx = gnext(n); | 509 | int nx = gnext(n); |
| @@ -520,7 +520,7 @@ const TValue *luaH_getstr (Table *t, TString *key) { | |||
| 520 | */ | 520 | */ |
| 521 | const TValue *luaH_get (Table *t, const TValue *key) { | 521 | const TValue *luaH_get (Table *t, const TValue *key) { |
| 522 | switch (ttype(key)) { | 522 | switch (ttype(key)) { |
| 523 | case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); | 523 | case LUA_TSHRSTR: return luaH_getstr(t, tsvalue(key)); |
| 524 | case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); | 524 | case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); |
| 525 | case LUA_TNIL: return luaO_nilobject; | 525 | case LUA_TNIL: return luaO_nilobject; |
| 526 | case LUA_TNUMFLT: { | 526 | case LUA_TNUMFLT: { |
