From 52b9524548adbae1a6ebe6039b253326c4d27323 Mon Sep 17 00:00:00 2001 From: pynappo Date: Sat, 15 Jun 2024 19:14:36 -0700 Subject: [PATCH] Removed redundant equality check for performance A valid local import spec never has `spec.import == M.LOCAL_SPEC` because by the time we do the check, we know that `find_local_spec()` succeeded (if it didn't, the spec:cond() check would have failed). Thus we only need to check if the modname ends with `'/' .. M.LOCAL_SPEC`. --- lua/lazy/core/plugin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 55e30a7..30b3c78 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -405,7 +405,7 @@ function Spec:import(spec) -- relies on `find_local_spec` to always insert a `/` before the local spec location local local_spec_suffix = "/" .. M.LOCAL_SPEC - if spec.import == M.LOCAL_SPEC or spec.import:sub(-#local_spec_suffix) == local_spec_suffix then + if spec.import:sub(-#local_spec_suffix) == local_spec_suffix then modnames = { spec.import } else Util.lsmod(spec.import, function(modname) @@ -418,7 +418,7 @@ function Spec:import(spec) imported = imported + 1 local name = modname local is_local_spec = false - if modname == M.LOCAL_SPEC or modname:sub(-#local_spec_suffix) == local_spec_suffix then + if modname:sub(-#local_spec_suffix) == local_spec_suffix then name = vim.fn.fnamemodify(modname, ":~:.") is_local_spec = true end