chore: try with a new implementation of difference
This commit is contained in:
parent
997fe76fd1
commit
86baeb83f0
@ -40,19 +40,15 @@ local function sizeof(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function difference(a, b)
|
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(a) do r[k] = v; ai[v]=true end
|
||||||
for k,v in pairs(b) do aa[v]=nil end
|
for k,v in pairs(b) do
|
||||||
|
if ai[v]~=nil then r[k] = 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ret
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
local function shallowClone(t)
|
local function shallowClone(t)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user