Originally Posted by Seerah
Lua Code:
frame1 = CreateFrame("frame","frame1",UIParent) frame2 = CreateFrame("frame","frame1",UIParent)
This creates 2 frames. The first is referenced by the global variable frame1 while the second is referenced by two global variables, frame1 and frame2. While the second frame's frame1 reference overwrites the first frame's reference, that does not mean that the second frame replaces the first. They both still exist.
|
Actually, this is incorrect. Two frames are indeed created, but the setting of the global variable from the frame name is more complex. To demonstrate, we'll run the following code.
Code:
f1=CreateFrame("Frame","f0");
f2=CreateFrame("Frame","f0");
print(f0,f1,f2);
Notice both frames are created with the name "f0", yet only the first one is stored in that global. This is confirmed by the first 2 pointers printed out being equal. This is because there's an internal check when a frame is created that restricts it to only set the frame name global if it doesn't exist.
Originally Posted by Wildbreath
For example:
frame1 = CreateFrame("frame","frame1",UIParent)
frame2 = CreateFrame("frame","frame1",UIParent)
frame1 == frame2 ?
or frame2 is new widget object?
If second is right then i have a new snippet for optimize all addons
|
As most authors use locals and table keys rather than globals for performance improvements, this method is practically useless.