View Single Post
09-20-17, 10:09 PM   #1
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Two addons showing high CPU usage, despite being small.

Hi, I was having some fps issues so I downloaded an addon monitoring addon and noticed that two small addons were showing high CPU usage relative to their size. Could anyone take a look for me?

Thanks.

1.
Lua Code:
  1. local SET_TEXT = TARGET .. ": |cff%02x%02x%02x%s|r"
  2. local MATCH_TEXT = "^" .. TARGET
  3.  
  4. local last
  5. GameTooltip:HookScript("OnUpdate", function(self)
  6.     local name = UnitName("mouseovertarget")
  7.     if not name or name == "" or not self:GetUnit() then return end
  8.     last = name
  9.  
  10.     local r, g, b
  11.     if UnitIsPlayer("mouseovertarget") then
  12.         local _, class = UnitClass("mouseovertarget")
  13.         local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  14.         r, g, b = color.r, color.g, color.b
  15.     else
  16.         r, g, b = GameTooltip_UnitColor("mouseovertarget")
  17.     end
  18.  
  19.     for i = 2, self:NumLines() do
  20.         local line = _G["GameTooltipTextLeft"..i]
  21.         if strfind(line:GetText() or "", MATCH_TEXT) then
  22.             line:SetFormattedText(SET_TEXT, r * 255, g * 255, b * 255, name)
  23.             return self:Show()
  24.         end
  25.     end
  26.     self:AddLine(format(SET_TEXT, r * 255, g * 255, b * 255, name))
  27.     self:Show()
  28. end)
  29.  
  30. GameTooltip:HookScript("OnTooltipSetUnit", function(GameTooltip)
  31.     local _, unit = GameTooltip:GetUnit()
  32.     if UnitIsPlayer(unit) then
  33.         local _, class = UnitClass(unit)
  34.         local color = class and (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  35.         if color then
  36.             local text = GameTooltipTextLeft1:GetText()
  37.             GameTooltipTextLeft1:SetFormattedText("|cff%02x%02x%02x%s|r", color.r * 255, color.g * 255, color.b * 255, text:match("|cff\x\x\x\x\x\x(.+)|r") or text)
  38.         end
  39.     end
  40. end)

2.
Lua Code:
  1. hooksecurefunc('CooldownFrame_Set', function(self)
  2.         if self.currentCooldownType == COOLDOWN_TYPE_LOSS_OF_CONTROL then
  3.                 self:SetCooldown(0,0)          
  4.         end
  5. end)
  6.  
  7. hooksecurefunc(getmetatable(CreateFrame('cooldown')).__index, 'SetCooldown', function(self)
  8.     self:SetDrawBling(false)
  9. end)
  Reply With Quote