add fifo_queue.add_list() and use it to eliminate an inner loop
This commit is contained in:
parent
a7c8146e71
commit
5be0ee97fb
|
@ -20,6 +20,11 @@ function fifo_queue.add(self, v)
|
|||
self.buf_in[n] = v
|
||||
end
|
||||
|
||||
-- add several elements to the queue
|
||||
function fifo_queue.add_list(self, v)
|
||||
table.move(v, 1, #v, self.n_in + 1, self.buf_in)
|
||||
self.n_in = self.n_in + #v
|
||||
end
|
||||
-- removes and returns the next element, or nil of empty
|
||||
function fifo_queue.take(self)
|
||||
local i_out = self.i_out
|
||||
|
|
|
@ -85,9 +85,10 @@ function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky)
|
|||
if minetest.registered_nodes[nn.name]
|
||||
and minetest.registered_nodes[nn.name].mvps_sticky then
|
||||
local connected = minetest.registered_nodes[nn.name].mvps_sticky(np, nn)
|
||||
for _, cp in ipairs(connected) do
|
||||
frontiers:add_list(connected)
|
||||
--[[for _, cp in ipairs(connected) do
|
||||
frontiers:add(cp)
|
||||
end
|
||||
end]]
|
||||
end
|
||||
|
||||
frontiers:add(vector.add(np, dir))
|
||||
|
|
Loading…
Reference in New Issue