Changed iterator behaviour to avoid allocating a closure each time.
This commit is contained in:
parent
37a3884ee2
commit
93670a314d
|
@ -169,18 +169,17 @@ function Doc:get_selection_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Doc:get_selections(sort)
|
function Doc:get_selections(sort)
|
||||||
local idx = 1
|
return function(selections, idx)
|
||||||
return function()
|
local target = idx*4 + 1
|
||||||
if idx >= #self.selections then
|
if target >= #selections then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
idx = idx + 4
|
|
||||||
if sort then
|
if sort then
|
||||||
return ((idx - 5) / 4) + 1, sort_positions(self.selections[idx - 4], self.selections[idx - 3], self.selections[idx - 2], self.selections[idx - 1])
|
return idx+1, sort_positions(selections[target], selections[target+1], selections[target+2], selections[target+3])
|
||||||
else
|
else
|
||||||
return ((idx - 5) / 4) + 1, self.selections[idx - 4], self.selections[idx - 3], self.selections[idx - 2], self.selections[idx - 1]
|
return idx+1, selections[target], selections[target+1], selections[target+2], selections[target+3]
|
||||||
end
|
end
|
||||||
end
|
end, self.selections, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue