Is this pattern optimized? #246
-
I use this pattern quite a lot throughout my code because I avoid having to write two or more repeated lines. Example: for _, storage in ipairs({"Backpack", "StarterGear"}) do
local clone = Item:Clone()
clone.Parent = player[storage]
end I use it more than just in this scenario, it's just the most recent I remembered. And I was wondering if I'm always actually creating this new table or if it's reused or not. This is somewhat of a question and an optimization suggestion 😅 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Right now this code does create a fresh table every time. We still currently live in the world where globals can be substituted externally via |
Beta Was this translation helpful? Give feedback.
Right now this code does create a fresh table every time. We still currently live in the world where globals can be substituted externally via
setfenv
which makes optimizing this correctly difficult (although it's possible we'll change the expectations for patching globals at some point...)