summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiaran Gultnieks <ciaran@ciarang.com>2014-02-15 12:22:07 +0000
committerCiaran Gultnieks <ciaran@ciarang.com>2014-02-15 12:59:22 +0000
commit6876aa6a4fbe042ccffad9be345bdf789f61bd67 (patch)
treeeb2cb31a365b3eff7d091d22506f42a4e1138e2d
parent78d67f00a6d18e96884bc4677b62573e6be46540 (diff)
Performance improvement when transmitting
The 'checked' table is passed by reference anyway, so reassigning it at every step along the network is just wasting time by creating more and more copies of it.
-rw-r--r--digilines/internal.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/digilines/internal.lua b/digilines/internal.lua
index ce4012c..9a4780c 100644
--- a/digilines/internal.lua
+++ b/digilines/internal.lua
@@ -66,9 +66,8 @@ function digiline:rules_link_anydir(output, input)
end
function digiline:transmit(pos, channel, msg, checked)
- checked = checked or {}
local checkedid = tostring(pos.x).."_"..tostring(pos.y).."_"..tostring(pos.z)
- if checked[checkedid] then return checked end
+ if checked[checkedid] then return end
checked[checkedid] = true
local node = minetest.env:get_node(pos)
@@ -86,9 +85,9 @@ function digiline:transmit(pos, channel, msg, checked)
local rules = digiline:importrules(spec.wire.rules, node)
for _,rule in ipairs(rules) do
if digiline:rules_link(pos, digiline:addPosRule(pos, rule)) then
- checked = digiline:transmit(digiline:addPosRule(pos, rule), channel, msg, checked)
+ digiline:transmit(digiline:addPosRule(pos, rule), channel, msg, checked)
end
end
end
- return checked
+ return
end