Skip to content

Commit

Permalink
perf: when reloading plugin specs always use cache
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 16, 2022
1 parent e897524 commit 060cf23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/lazy/core/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function M.loader(modname)
return chunk or error(err)
end

function M.require(modname)
return M.loader(modname)()
end

function M.idx()
-- update our loader position if needed
if package.loaders[M.loader_idx] ~= M.loader then
Expand Down
3 changes: 2 additions & 1 deletion lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local Config = require("lazy.core.config")
local Util = require("lazy.core.util")
local Handler = require("lazy.core.handler")
local Cache = require("lazy.core.cache")

local M = {}

Expand Down Expand Up @@ -217,7 +218,7 @@ function M.spec()
---@diagnostic disable-next-line: no-unknown
package.loaded[modname] = nil
Util.try(function()
spec:normalize(require(modname))
spec:normalize(Cache.require(modname))
end, "Failed to load **" .. modname .. "**")
end
local path_plugins = vim.fn.stdpath("config") .. "/lua/" .. Config.spec:gsub("%.", "/")
Expand Down

0 comments on commit 060cf23

Please sign in to comment.