Skip to content

Commit

Permalink
refactor(main): init keys table with hardcoded "false" instead of cur…
Browse files Browse the repository at this point in the history
…rent fenster->keys value

Same result but less CPU usage
  • Loading branch information
jonasgeiler committed May 29, 2024
1 parent 8699919 commit f07f0fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/main_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ describe('fenster', function()
local index = 0
while window.keys[index] ~= nil do
assert.is_boolean(window.keys[index])
assert.is_false(window.keys[index])
index = index + 1
end
assert.is_equal(index, 256)
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static int lfenster_open(lua_State *L) {
// initialize the keys table and put it in the registry
lua_createtable(L, KEYS_LENGTH, 0);
for (int i = 0; i < KEYS_LENGTH; i++) {
lua_pushboolean(L, p_fenster->keys[i]);
lua_pushboolean(L, 0);
lua_rawseti(L, -2, i);
}
lua_pushvalue(L, -1); // copy the keys table since luaL_ref pops it
Expand Down

0 comments on commit f07f0fc

Please sign in to comment.