Skip to content

Commit 060cf23

Browse files
committed
perf: when reloading plugin specs always use cache
1 parent e897524 commit 060cf23

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lua/lazy/core/cache.lua

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ function M.loader(modname)
9292
return chunk or error(err)
9393
end
9494

95+
function M.require(modname)
96+
return M.loader(modname)()
97+
end
98+
9599
function M.idx()
96100
-- update our loader position if needed
97101
if package.loaders[M.loader_idx] ~= M.loader then

lua/lazy/core/plugin.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local Config = require("lazy.core.config")
22
local Util = require("lazy.core.util")
33
local Handler = require("lazy.core.handler")
4+
local Cache = require("lazy.core.cache")
45

56
local M = {}
67

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

0 commit comments

Comments
 (0)