From 86baeb83f04fabc08824fda06ea48d7cd40ff1a4 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Mon, 20 May 2024 19:58:11 +0200 Subject: [PATCH] chore: try with a new implementation of difference --- inferium-harvester.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/inferium-harvester.lua b/inferium-harvester.lua index 1d73fee..8542139 100644 --- a/inferium-harvester.lua +++ b/inferium-harvester.lua @@ -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)