Quantcast WoWInterface - View Single Post - Chat Addon Optimization
View Single Post
07-07-19, 12:28 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,698
All these table.inserts are totally unnecessary. Not only is it both a global and table lookup, but it's also a function call. At least this section of code only runs once, but it is much quicker and simpler to read if you just fill in the table when you create it.
Lua Code:
  1. local eventTable = {
  2.      'CHAT_MSG_SAY',
  3.      'CHAT_MSG_YELL',
  4.      --etc.
  5. }

Not a big deal, but why do you have two separate frames? (f and g) You only have one event registered to g, so you could just condense them. This is the whole reason why the event parameter is passed through to the function.
Lua Code:
  1. f:SetScript("OnEvent", function(self, event, ...)
  2.      if event == "UPDATE_CHAT_COLOR" then
  3.           --do this stuff here
  4.      else
  5.           --do the other stuff
  6.      end
  7. end)

Why are you calling ChatFrame_AddMessageEventFilter for all of these events and hiding all of these messages from chat? By doing this and then using your commonChatEventHandler and only adding a message to ChatFrame1, you are overriding any user's preferred location of displaying messages.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote