From 1c16bdda99c40c37ddf5f1c477a8a8b87305e3cb Mon Sep 17 00:00:00 2001 From: Xinhuan Date: Sun, 7 Dec 2008 17:30:19 +0800 Subject: [PATCH] Put a throtle on the UpdateBars function, reducing CPU usage to about 20%-40% compared to before, with no loss of threat updates (more savings when in a larger raid). --- Omen.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Omen.lua b/Omen.lua index 071fccd..5679321 100644 --- a/Omen.lua +++ b/Omen.lua @@ -1313,8 +1313,19 @@ function Omen:FindThreatMob() self.unitID = nil end -local queried = false +-- Frame for throtling updates +local OmenUpdateBarsThrotleFrame = CreateFrame("Frame") +OmenUpdateBarsThrotleFrame:Hide() +OmenUpdateBarsThrotleFrame:SetScript("OnUpdate", function(self, elapsed) + self:Hide() + Omen:UpdateBarsReal() +end) function Omen:UpdateBars() + OmenUpdateBarsThrotleFrame:Show() +end + +local queried = false +function Omen:UpdateBarsReal() if db.Autocollapse and db.CollapseHide then -- Update the visibility because it could have been hidden on 0 bars self.BarList.barsShown = 1 -- Dummy value @@ -1325,8 +1336,6 @@ function Omen:UpdateBars() return end - -- TODO: Put a update throtle on this function - local myGUID = UnitGUID("player") local dbBar = db.Bar local mob, mobGUID, mobTargetGUID