View Single Post
04-18-09, 12:15 AM   #13
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by haste View Post
Premature optimization. Your design is obviously corrupted by this. You shouldn't really worry about the overhead in a OnUpdate from locals. Unless you create a bunch of tables on every OnUpdate, but then we're back to flawed design.

The overhead from locals is also far from nuts.
No.


Originally Posted by ChaosInc View Post
Ok, no offense mate, but don't edit a different code into it when people are trying to help you figure out the original. I was confused there for a sec...

Try separating the function out to test functionality better:
Code:
local f = CreateFrame("Blah")
f:SetScript("OnUpdate", testfunction(self))

function testfunction(frame)
    if not foo then 
        local foo,bar="foo","bar"
    end
    text=foo..bar
    DEFAULT_CHAT_FRAME:AddMessage(text)  -- test to make sure everything goes smoothly
end
Also note that I removed local text = "" as you don't need it. It's already going to be overridden each time without having to manually clear it. After you get it working how you want, then go back and optimize the code (as haste pointed out).
Was just simplifying the example to make it easier to understand, and hadn't seen your reply yet.

Yes text is supposed to be overwritten in the example.. and it's supposed to be a local.


BTW your example is broken.

Even after fixing the CreateFrame, it says "attempt to call function 'testfunction', a nil value" and I don't know how to fix that, since it's defined right there clear as day. :s


Edit: fixed it by moving it over the OnUpdate.. and now it says it's trying to concatenate foo as a GLOBAL, and that it's NIL. Just like in my example.

Last edited by Azul : 04-18-09 at 12:21 AM.