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.)
This commit is contained in:
5
lapi.c
5
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user