feat: lazy caching now works with functions that have upvalues

This commit is contained in:
Folke Lemaitre 2022-11-25 15:35:40 +01:00
parent 48199f8031
commit fe33e4e3dd
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
9 changed files with 161 additions and 187 deletions

View file

@ -27,6 +27,20 @@ function M.track(name, time)
end
end
-- Fast implementation to check if a table is a list
---@param t table
function M.is_list(t)
local i = 0
---@diagnostic disable-next-line: no-unknown
for _ in pairs(t) do
i = i + 1
if t[i] == nil then
return false
end
end
return true
end
function M.very_lazy()
local function _load()
vim.defer_fn(function()