perf: removed partial spec caching. not worth the tiny performance boost

This commit is contained in:
Folke Lemaitre 2022-11-30 00:18:59 +01:00
parent 9be3d3d840
commit 4438faf9a9
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
8 changed files with 77 additions and 228 deletions

View file

@ -5,13 +5,9 @@ local M = {}
---@type table<string, string>
M.hashes = {}
function M.is_dirty(modname, modpath)
return not (Cache.get(modname) and M.hashes[modname] and M.hashes[modname] == Cache.hash(modpath))
end
---@param modname string
---@param modpath string
---@return any, boolean
---@return any
function M.load(modname, modpath)
local err
---@type (string|fun())?
@ -24,9 +20,7 @@ function M.load(modname, modpath)
chunk = nil
end
local cached = false
if chunk then
cached = true
chunk, err = load(chunk --[[@as string]], "@" .. modpath, "b")
else
vim.schedule(function()
@ -39,7 +33,7 @@ function M.load(modname, modpath)
end
if chunk then
return chunk(), cached
return chunk()
else
error(err)
end