Skip to content

Commit 0cee848

Browse files
pablomayobrerm-code
authored andcommitted
Clear the changes table using the for loop
Instead of allocating a new table, it can be cleared by using the same for loop as the check for changes.
1 parent b5b1423 commit 0cee848

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ScreenManager.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,10 @@ end
126126
-- @see push, pop, switch
127127
--
128128
function ScreenManager.performChanges()
129-
if #changes == 0 then
130-
return
131-
end
129+
for i=1, #changes do
130+
local change = changes[i]
131+
changes[i] = nil
132132

133-
for _, change in ipairs( changes ) do
134133
if change.action == 'pop' then
135134
pop()
136135
elseif change.action == 'switch' then
@@ -140,8 +139,6 @@ function ScreenManager.performChanges()
140139
push( change.screen, change.args )
141140
end
142141
end
143-
144-
changes = {}
145142
end
146143

147144
---

0 commit comments

Comments
 (0)