From ff01073eeee92bf633a15c625d85d940a2e0da52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Mon, 6 Mar 2017 10:28:42 +0000 Subject: set: aggregate: also dedup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- lua/inet/set.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/inet/set.lua b/lua/inet/set.lua index effb0f2..27c9388 100644 --- a/lua/inet/set.lua +++ b/lua/inet/set.lua @@ -33,11 +33,17 @@ function M.aggregate(t) if ia then local ib = ia:flip() -- counterpart for j=1,n do - if j ~= i and t[j] == ib then - -- counterpart found, aggregating - t[i] = (ia ^ -1):network() - t[j] = nil - flag = true + if j ~= i then + if ia == t[j] then + -- duplicate found + t[j] = nil + flag = true + elseif t[j] == ib then + -- counterpart found, aggregating + t[i] = (ia ^ -1):network() + t[j] = nil + flag = true + end end end end -- cgit v1.2.1