@@ -3798,6 +3798,37 @@ local function itemChangesPassiveTreeRadius(item)
37983798 and (item .jewelData .conqueredBy or item .jewelData .intuitiveLeapLike or item .jewelData .impossibleEscapeKeystone ))
37993799end
38003800
3801+ local function getStoredItemId (itemsTab , item )
3802+ if not item then
3803+ return " "
3804+ end
3805+ local itemId = item .id
3806+ if itemId and itemsTab .items [itemId ] == item then
3807+ return tostring (itemId )
3808+ end
3809+ end
3810+
3811+ local function getJewelComparisonOutputCache (itemsTab )
3812+ local outputRevision = itemsTab .build and itemsTab .build .outputRevision or 0
3813+ local cache = itemsTab .jewelComparisonOutputCache
3814+ if not cache or cache .outputRevision ~= outputRevision then
3815+ cache = {
3816+ outputRevision = outputRevision ,
3817+ outputs = { },
3818+ }
3819+ itemsTab .jewelComparisonOutputCache = cache
3820+ end
3821+ return cache
3822+ end
3823+
3824+ local function getJewelComparisonOutputCacheKey (itemsTab , compareSlot , replacementItem )
3825+ local replacementItemId = getStoredItemId (itemsTab , replacementItem )
3826+ if not replacementItemId then
3827+ return
3828+ end
3829+ return tostring (compareSlot .slotName ) .. " :" .. tostring (compareSlot .nodeId or " " ) .. " :" .. tostring (compareSlot .selItemId or " " ) .. " :" .. replacementItemId
3830+ end
3831+
38013832-- Radius jewels can change conquered nodes and orphaned allocations, so compare
38023833-- against a rebuilt spec instead of approximating the diff with removeNodes.
38033834-- Keep this list in sync with PassiveSpec's constructor, Init, and Select*
@@ -4562,13 +4593,27 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
45624593
45634594 tooltip :AddLine (14 , colorCodes .TIP .. " Tip: Press Ctrl+D to disable the display of stat differences." )
45644595
4565- local function getReplacedItemAndOutput (compareSlot , selItem , useJewelComparisonSpecCache )
4596+ local function getReplacedItemAndOutput (compareSlot , selItem , useJewelComparisonSpecCache , useJewelComparisonOutputCache )
45664597 selItem = selItem or self .items [compareSlot .selItemId ]
45674598 local override = { repSlotName = compareSlot .slotName , repItem = item ~= selItem and item or nil }
4599+ local outputCache
4600+ local outputCacheKey
45684601 if compareSlot .nodeId and (itemChangesPassiveTreeRadius (selItem ) or itemChangesPassiveTreeRadius (item )) then
4602+ if useJewelComparisonOutputCache then
4603+ outputCacheKey = getJewelComparisonOutputCacheKey (self , compareSlot , override .repItem )
4604+ if outputCacheKey then
4605+ outputCache = getJewelComparisonOutputCache (self )
4606+ if outputCache .outputs [outputCacheKey ] then
4607+ return selItem , outputCache .outputs [outputCacheKey ]
4608+ end
4609+ end
4610+ end
45694611 override .spec = buildSpecForJewelComparison (self , compareSlot , override .repItem , useJewelComparisonSpecCache )
45704612 end
45714613 local output = calcFunc (override )
4614+ if outputCacheKey then
4615+ outputCache .outputs [outputCacheKey ] = output
4616+ end
45724617 return selItem , output
45734618 end
45744619 local function addCompareForSlot (compareSlot , selItem , output , useJewelComparisonSpecCache )
@@ -4610,7 +4655,7 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
46104655 local slots = {}
46114656 for _ , slotEntry in ipairs (slotCandidates ) do
46124657 if not isLimitedUniqueAtLimit or slotEntry .isSameUnique then
4613- local _ , output = getReplacedItemAndOutput (slotEntry .compareSlot , slotEntry .selItem )
4658+ local _ , output = getReplacedItemAndOutput (slotEntry .compareSlot , slotEntry .selItem , nil , true )
46144659 slotEntry .output = output
46154660 table.insert (slots , slotEntry )
46164661 end
0 commit comments