Skip to content

Commit f07f0fc

Browse files
committed
refactor(main): init keys table with hardcoded "false" instead of current fenster->keys value
Same result but less CPU usage
1 parent 8699919 commit f07f0fc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

spec/main_spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ describe('fenster', function()
564564
local index = 0
565565
while window.keys[index] ~= nil do
566566
assert.is_boolean(window.keys[index])
567+
assert.is_false(window.keys[index])
567568
index = index + 1
568569
end
569570
assert.is_equal(index, 256)

src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static int lfenster_open(lua_State *L) {
184184
// initialize the keys table and put it in the registry
185185
lua_createtable(L, KEYS_LENGTH, 0);
186186
for (int i = 0; i < KEYS_LENGTH; i++) {
187-
lua_pushboolean(L, p_fenster->keys[i]);
187+
lua_pushboolean(L, 0);
188188
lua_rawseti(L, -2, i);
189189
}
190190
lua_pushvalue(L, -1); // copy the keys table since luaL_ref pops it

0 commit comments

Comments
 (0)