From 6aff28a118b5cdd8fa41ec3b2d9fae649e5911a2 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Tue, 13 Jun 2023 03:15:52 +0200 Subject: [PATCH] remove list purging we already purge empty items before calling has_room_for_in, so no need to do it here anymore --- autocrafter.lua | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 201f77e..0ccc274 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -55,30 +55,19 @@ local function has_room_for_in(list_src, list_dst) i = i - 1 until i == 0 - -- purge empty slots from source list - local src = {} - i = #list_src - if i > 0 then -- jic - repeat - if not list_src[i]:is_empty() then - src[#src + 1] = list_src[i] - end - i = i - 1 - until i == 0 - end -- Shortcut check is safe as we can expect all stacks in list_src -- to have valid stack sizes. -- If there are plenty empty slots, confirm to have space. - if #indexes.__empty__ >= #src then return true end + if #indexes.__empty__ >= #list_src then return true end -- try adding each stack to slots until stacks are empty local j, done - i = #src + i = #list_src if i == 0 then return true end -- sanity check jic repeat done = false - stack = ItemStack(src[i]) + stack = ItemStack(list_src[i]) name = stack:get_name() -- first try stacks with same item name if indexes[name] then