KamberQuests

KamberQuests

465 Downloads

Optimization Opportunities

Radbarn opened this issue ยท 1 comments

commented

cache the currentMapID and similar variables and only update then when the map-change events trigger instead of every time the code checks IsQuestInCurrentZone

further prioritize questHeaderIndex name checks after caching the variables -- this should capture most of the quests and cut off the remainder of the code executing

explore optimizing the UpdateQuestWatch function to check which events fired and if any KQ settings have changed to restrict what needs to be checked?

use a function within the zone check function to optimize
-- Cache Expensive API Calls:
local currentMapID, questMapID, currentMapName

-- Optimized IsQuestInCurrentZone Function
local function IsQuestInCurrentZone(questID)
currentMapID = currentMapID or C_Map.GetBestMapForUnit("player")
currentMapName = currentMapName or currentMapID and C_Map.GetMapInfo(currentMapID).name
questMapID = questMapID or C_QuestLog.GetMapForQuestPOIs(questID)

-- Prioritize faster checks
if currentMapName then
    local questHeaderIndex = C_QuestLog.GetHeaderIndexForQuest(questID)
    if questHeaderIndex then
        local questHeaderZoneText = C_QuestLog.GetTitleForLogIndex(questHeaderIndex)
        if questHeaderZoneText == currentMapName then
            return true
        end
    end
end

-- Only check map quests if necessary
local function CheckQuestsOnMap(mapID)
    if mapID then
        for _, questInfo in ipairs(C_QuestLog.GetQuestsOnMap(mapID)) do
            if questInfo.questID == questID then
                return true
            end
        end
    end
    return false
end
return CheckQuestsOnMap(currentMapID) or CheckQuestsOnMap(questMapID)

end

commented

V1.4.0 included these optimizations