diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-01-06 11:38:31 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-01-06 11:38:31 -0300 |
| commit | 5ff408d2189c6c24fdf8908db4a31432bbdd6f15 (patch) | |
| tree | bcd83d7547dab0d5418116eb10f9c601f2f2d3b9 /ltable.c | |
| parent | e3c83835e7b396ab7db538fb3b052f02d7807dee (diff) | |
| download | lua-github-5ff408d2189c6c24fdf8908db4a31432bbdd6f15.tar.gz | |
Changed internal representation of booleans
Instead of an explicit value (field 'b'), true and false use different
tag variants. This avoids reading an extra field and results in more
direct code. (Most code that uses booleans needs to distinguish between
true and false anyway.)
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -143,8 +143,10 @@ static Node *mainposition (const Table *t, int ktt, const Value *kvl) { return hashstr(t, tsvalueraw(*kvl)); case LUA_TLNGSTR: return hashpow2(t, luaS_hashlongstr(tsvalueraw(*kvl))); - case LUA_TBOOLEAN: - return hashboolean(t, bvalueraw(*kvl)); + case LUA_TFALSE: + return hashboolean(t, 0); + case LUA_TTRUE: + return hashboolean(t, 1); case LUA_TLIGHTUSERDATA: return hashpointer(t, pvalueraw(*kvl)); case LUA_TLCF: @@ -175,14 +177,12 @@ static int equalkey (const TValue *k1, const Node *n2) { if (rawtt(k1) != keytt(n2)) /* not the same variants? */ return 0; /* cannot be same key */ switch (ttypetag(k1)) { - case LUA_TNIL: + case LUA_TNIL: case LUA_TFALSE: case LUA_TTRUE: return 1; case LUA_TNUMINT: return (ivalue(k1) == keyival(n2)); case LUA_TNUMFLT: return luai_numeq(fltvalue(k1), fltvalueraw(keyval(n2))); - case LUA_TBOOLEAN: - return bvalue(k1) == bvalueraw(keyval(n2)); case LUA_TLIGHTUSERDATA: return pvalue(k1) == pvalueraw(keyval(n2)); case LUA_TLCF: |
