chore: try with a new implementation of difference

This commit is contained in:
Guillaume ARM 2024-05-20 19:58:11 +02:00
parent 997fe76fd1
commit 86baeb83f0

View File

@ -40,19 +40,15 @@ local function sizeof(t)
end
local function difference(a, b)
local aa = {}
local ai = {}
local r = {}
for k,v in pairs(a) do aa[v]=true end
for k,v in pairs(b) do aa[v]=nil end
local ret = {}
local n = 0
for k,v in pairs(a) do
if aa[v] then n=n+1 ret[n]=v end
for k,v in pairs(a) do r[k] = v; ai[v]=true end
for k,v in pairs(b) do
if ai[v]~=nil then r[k] = nil end
end
return ret
return r
end
local function shallowClone(t)