View Single Post
01-17-13, 11:21 AM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Express a val from a local table as local?

Hi there again.

All of my frames are contained within a table called 'Frames' which itself is in the addon table.

At the start of each of my modules, the table is declared as:

Lua Code:
  1. local f = V.Frames[module];    -- ie, in this case local f = V.Frames.Chat;

Whenever I'm writing functions though, I've always been in the habit of expressing each frame (which will be used within that function) as a local:

Lua Code:
  1. local cW = f.chatWindow;

I caught myself doing this 10 minutes ago, and now that I've got thinking about it, is it actually essential? The 'Frames' table (f) is already declared as a local after all. Should I just be using 'f.chatWindow' rather than 'cW'.

I know that each time I use f.chatWindow, it costs a local table lookup and that's what got me thinking. I'd much rather just reference each frame as f.xxxx to be honest, but I don't want to impact on performance unless said impact is infinitesimal.

I guess what I'm really asking is, does it make a big enough difference, performance-wise, to force me to declare them as locals as above?

Or does it really just depend on how many times I need to reference the frame in that particular function? For example, if I need to reference it 10/20/50 times, declare it as a local, whereas if it's just twice, don't bother?

Is the difference infinitesimal regardless of how many times the table value is called (within reason)?

Thank you again for any advice


Aanson.

EDIT: Spelling error.
__________________
__________________

Last edited by Aanson : 01-17-13 at 11:39 AM.
  Reply With Quote