summaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-01-06 11:38:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-01-06 11:38:31 -0300
commit5ff408d2189c6c24fdf8908db4a31432bbdd6f15 (patch)
treebcd83d7547dab0d5418116eb10f9c601f2f2d3b9 /ltable.c
parente3c83835e7b396ab7db538fb3b052f02d7807dee (diff)
downloadlua-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.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ltable.c b/ltable.c
index cc3c3dd4..ebd45dda 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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: