From 5ff408d2189c6c24fdf8908db4a31432bbdd6f15 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 Jan 2020 11:38:31 -0300 Subject: 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.) --- lapi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 073baa4d..0e99abef 100644 --- a/lapi.c +++ b/lapi.c @@ -574,7 +574,10 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { LUA_API void lua_pushboolean (lua_State *L, int b) { lua_lock(L); - setbvalue(s2v(L->top), (b != 0)); /* ensure that true is 1 */ + if (b) + setbtvalue(s2v(L->top)); + else + setbfvalue(s2v(L->top)); api_incr_top(L); lua_unlock(L); } -- cgit v1.2.3-55-g6feb