Reduce queue size

This commit is contained in:
number Zero 2018-01-28 02:19:24 +03:00
parent 054494abb6
commit 2cd2093b33

View File

@ -190,9 +190,13 @@ local get_network = function(sw_pos, pos1, tier)
local all_nodes = {} local all_nodes = {}
local queue = {} local queue = {}
add_cable_node(all_nodes, pos1, network_id, queue) add_cable_node(all_nodes, pos1, network_id, queue)
for _, pos in ipairs(queue) do while next(queue) do
traverse_network(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, local to_visit = {}
pos, technic.machines[tier], tier, sw_pos, network_id, queue) for _, pos in ipairs(queue) do
traverse_network(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes,
pos, technic.machines[tier], tier, sw_pos, network_id, to_visit)
end
queue = to_visit
end end
PR_nodes = flatten(PR_nodes) PR_nodes = flatten(PR_nodes)
BA_nodes = flatten(BA_nodes) BA_nodes = flatten(BA_nodes)