perf(init): skip redundant database compilation

This commit is contained in:
Aron
2026-07-05 16:26:12 +02:00
parent 558aeb3888
commit 1f3d5fbb61
3 changed files with 72 additions and 6 deletions
+47
View File
@@ -4,6 +4,28 @@ local QuestiePluginAPI = QuestieLoader:CreateModule("QuestiePluginAPI")
QuestiePluginAPI.registeredPlugins = {}
QuestiePluginAPI.loadedDBFlavor = nil -- set by the first DB plugin that calls FinishLoading
QuestiePluginAPI.pendingPluginsCount = 0 -- count of plugins that have registered but not yet FinishedLoading
QuestiePluginAPI.loadedDBVersions = {}
local KNOWN_PLUGIN_ADDONS = {
WotLKDB = "Questie-X-WotLKDB",
ClassicDB = "Questie-X-ClassicDB",
TBCDB = "Questie-X-TBCDB",
Ascension = "Questie-X-AscensionDB",
AscensionDB = "Questie-X-AscensionDB",
Ebonhold = "Questie-X-EbonholdDB",
EbonholdDB = "Questie-X-EbonholdDB",
Valanior = "Questie-X-ValaniorDB",
ValaniorDB = "Questie-X-ValaniorDB",
RetailDB = "Questie-X-RetailDB",
}
local function GetPluginAddonVersion(pluginName, flavorKey)
local addonName = KNOWN_PLUGIN_ADDONS[flavorKey] or KNOWN_PLUGIN_ADDONS[pluginName] or pluginName
if GetAddOnMetadata then
return GetAddOnMetadata(addonName, "Version") or "unknown"
end
return "unknown"
end
--- Returns true if at least one DB plugin has fully loaded.
---@return boolean
@@ -27,6 +49,27 @@ function QuestiePluginAPI:GetLoadedFlavor()
return self.loadedDBFlavor
end
--- Returns a stable signature for loaded DB plugin data.
---@return string
function QuestiePluginAPI:GetLoadedSignature()
local parts = {}
local pluginName, plugin = next(self.registeredPlugins)
while pluginName do
local version = self.loadedDBVersions[pluginName] or plugin.version or "pending"
local flavor = plugin.flavorKey or pluginName
local stats = plugin.stats or {}
parts[#parts + 1] = pluginName .. ":" .. flavor .. ":" .. version
.. ":Q" .. tostring(stats.QUEST or 0)
.. ":N" .. tostring(stats.NPC or 0)
.. ":O" .. tostring(stats.OBJECT or 0)
.. ":I" .. tostring(stats.ITEM or 0)
pluginName, plugin = next(self.registeredPlugins, pluginName)
end
table.sort(parts)
return table.concat(parts, "|")
end
---@class QuestiePlugin
local QuestiePlugin = {}
QuestiePlugin.__index = QuestiePlugin
@@ -298,6 +341,10 @@ function QuestiePlugin:FinishLoading(flavorKey)
QuestiePluginAPI.loadedDBFlavor = self.name
end
self.flavorKey = flavorKey or self.name
self.version = GetPluginAddonVersion(self.name, self.flavorKey)
QuestiePluginAPI.loadedDBVersions[self.name] = self.version
if not self.isFinished then
self.isFinished = true
QuestiePluginAPI.pendingPluginsCount = math.max(0, QuestiePluginAPI.pendingPluginsCount - 1)