Thread Tools Display Modes
11-13-10, 05:25 PM   #1
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
FYI, the lines I've marked in red are unnecessary and do nothing but consume CPU cycles. Since your frame is only registered for those three events, and you want to run the same code in response to all three events, there's no need to check if the event is one of the three; frames only receive events they have registered for.

Code:
f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
f:RegisterEvent("WORLD_MAP_UPDATE")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self, event)
	if event == "ZONE_CHANGED_NEW_AREA" or event == "WORLD_MAP_UPDATE" or event == "PLAYER_ENTERING_WORLD" then
		local zone = GetRealZoneText()
		if zone and zone ~= "" then
			return ZoneChange(zone)
		end
	end
end)
You're also creating an extra function closure (wastes memory) for no particular reason; since your addon is only running the code inside the ZoneChange function in response to events, you should just put that code directly inside the event handler.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Graphic presets


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off