From 812bb3c8b76e5102d7d391fd7bbfcdfd0bbe506b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 29 Nov 2022 20:26:30 +0100 Subject: [PATCH] perf: dont loop over handlers to determine if a plugin should be opt=true --- lua/lazy/core/plugin.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 7b380eb..0da99fc 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -205,14 +205,13 @@ function M.update_state(opts) plugin._ = plugin._ or {} plugin[1] = plugin["1"] or plugin[1] if plugin.opt == nil then - local has_handler = false - for handler, _ in pairs(Handler.handlers) do - if plugin[handler] then - has_handler = true - break - end - end - plugin.opt = plugin.dep or has_handler or Config.options.opt + plugin.opt = plugin.dep + or Config.options.opt + or plugin.module + or plugin.event + or plugin.keys + or plugin.ft + or plugin.cmd end local opt = plugin.opt and "opt" or "start" plugin.dir = Config.options.packpath .. "/" .. opt .. "/" .. plugin.name