fix(perf): explorer was creating new table for each new entry

augment performance on large folder by a factor of 10.
my /nix/store explorer goes from ~12sec to ~1.5sec.
This commit is contained in:
kiyan
2022-07-29 09:35:15 +02:00
parent 7fcb48c852
commit 665813b9e6
2 changed files with 10 additions and 1 deletions

View File

@@ -305,6 +305,14 @@ function M.key_by(tbl, key)
return keyed
end
function M.bool_record(tbl, key)
local keyed = {}
for _, val in ipairs(tbl) do
keyed[val[key]] = true
end
return keyed
end
local function timer_stop_close(timer)
if timer:is_active() then
timer:stop()