perf: when reloading plugin specs always use cache

This commit is contained in:
Folke Lemaitre 2022-12-16 15:08:09 +01:00
parent e897524b1f
commit 060cf23aca
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 6 additions and 1 deletions

View File

@ -92,6 +92,10 @@ function M.loader(modname)
return chunk or error(err) return chunk or error(err)
end end
function M.require(modname)
return M.loader(modname)()
end
function M.idx() function M.idx()
-- update our loader position if needed -- update our loader position if needed
if package.loaders[M.loader_idx] ~= M.loader then if package.loaders[M.loader_idx] ~= M.loader then

View File

@ -1,6 +1,7 @@
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Util = require("lazy.core.util") local Util = require("lazy.core.util")
local Handler = require("lazy.core.handler") local Handler = require("lazy.core.handler")
local Cache = require("lazy.core.cache")
local M = {} local M = {}
@ -217,7 +218,7 @@ function M.spec()
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
package.loaded[modname] = nil package.loaded[modname] = nil
Util.try(function() Util.try(function()
spec:normalize(require(modname)) spec:normalize(Cache.require(modname))
end, "Failed to load **" .. modname .. "**") end, "Failed to load **" .. modname .. "**")
end end
local path_plugins = vim.fn.stdpath("config") .. "/lua/" .. Config.spec:gsub("%.", "/") local path_plugins = vim.fn.stdpath("config") .. "/lua/" .. Config.spec:gsub("%.", "/")