diff --git a/Core/CacheWarmer.lua b/Core/CacheWarmer.lua index 640dd43..bfb240b 100644 --- a/Core/CacheWarmer.lua +++ b/Core/CacheWarmer.lua @@ -23,8 +23,11 @@ function CacheWarmer:WarmBagScanner() end -- Walk player bags 0-4 and queue one ItemDetection:GetItemProperties per --- occupied slot. The work queue spreads them across frames within the --- existing 100ms-per-frame budget. +-- occupied slot, plus Utils:GetConsumableRestoreTag for consumables. The +-- work queue spreads them across frames within the existing 100ms-per-frame +-- budget. This warms both tooltip caches the bag-open path reads +-- (ItemDetection.detectionCache and Utils.tooltipCache.restoreTag), so the +-- first bag open doesn't pay for synchronous tooltip scans. function CacheWarmer:WarmItemDetectionCache() local Utils = Guda.Modules.Utils local ItemDetection = Guda.Modules.ItemDetection @@ -45,6 +48,17 @@ function CacheWarmer:WarmItemDetectionCache() -- the tooltip scan. ItemDetection:GetItemProperties({ link = l }, b, s) end, "CacheWarmer.itemDetection") + + -- Warm the consumable restoreTag cache too. Only consumables + -- ever carry the relevant tooltip lines, so check class via + -- GetItemInfo (cached by the client after the detection scan + -- above) and queue only matching items. + Utils:QueueWork(function() + local _, _, _, _, itemType = GetItemInfo(l) + if itemType == "Consumable" and Utils.GetConsumableRestoreTag then + Utils:GetConsumableRestoreTag(b, s, l) + end + end, "CacheWarmer.restoreTag") end end end diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index 58cda02..f9258f9 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -108,12 +108,14 @@ local function ScheduleDeferredUsabilityCheck() if this.elapsed >= USABILITY_CHECK_DELAY then this:Hide() this.pending = false - -- Only run if bag is still open + -- Only run if bag is still open. + -- Note: we intentionally do NOT ClearCache here. GetItemProperties + -- already refuses to cache partial-tooltip scans (tooltipLooksComplete + -- guard in ItemDetection), so rescanning naturally re-hits items + -- whose first scan was incomplete while leaving good cache entries + -- intact — wiping the cache would defeat CacheWarmer and force a + -- full ~80-item tooltip burst every open. if Guda_BagFrame and Guda_BagFrame:IsShown() then - -- Clear detection cache and re-check all items - if addon.Modules.ItemDetection and addon.Modules.ItemDetection.ClearCache then - addon.Modules.ItemDetection:ClearCache() - end UpdateAllUsabilityTints() end end diff --git a/UI/FrameHelpers.lua b/UI/FrameHelpers.lua index 80e363d..c7a201d 100644 --- a/UI/FrameHelpers.lua +++ b/UI/FrameHelpers.lua @@ -23,8 +23,12 @@ function Guda_CategorizeItem(itemData, bagID, slotID, categories, specialItems, local itemName = itemData.name or "" local cat = "Miscellaneous" - -- Detect consumable restore/eat/drink tag for current character only - if not isOtherChar and addon.Modules.Utils and addon.Modules.Utils.GetConsumableRestoreTag then + -- Detect consumable restore/eat/drink tag for current character only. + -- Gated on class == "Consumable": the "while eating"/"while drinking"/"use: + -- restores" patterns only appear on consumables, so scanning other items + -- just wastes a tooltip roundtrip per bag on the cold-cache path. + if not isOtherChar and itemData.class == "Consumable" + and addon.Modules.Utils and addon.Modules.Utils.GetConsumableRestoreTag then local tag = addon.Modules.Utils:GetConsumableRestoreTag(bagID, slotID) if tag then itemData.restoreTag = tag