From f91dfe7efa1fc9a449a5de1f12b2f27c0d7c87ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Mon, 13 May 2024 17:01:33 +0200 Subject: [PATCH] Misc optimization --- ArchiSteamFarm/Steam/Exchange/Trading.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/Steam/Exchange/Trading.cs b/ArchiSteamFarm/Steam/Exchange/Trading.cs index 3157115e4..022524ac8 100644 --- a/ArchiSteamFarm/Steam/Exchange/Trading.cs +++ b/ArchiSteamFarm/Steam/Exchange/Trading.cs @@ -130,9 +130,10 @@ public sealed class Trading : IDisposable { // Once we have initial state, we remove items that we're supposed to give from our inventory // This loop is a bit more complex due to the fact that we might have a mix of the same item splitted into different amounts + HashSet itemsToRemove = []; + foreach (Asset itemToGive in itemsToGive) { uint amountToGive = itemToGive.Amount; - HashSet itemsToRemove = []; foreach (Asset item in inventoryState.Where(item => (item.AppID == itemToGive.AppID) && (item.ClassID == itemToGive.ClassID) && (item.InstanceID == itemToGive.InstanceID))) { if (amountToGive >= item.Amount) { @@ -154,6 +155,8 @@ public sealed class Trading : IDisposable { if (itemsToRemove.Count > 0) { inventoryState.ExceptWith(itemsToRemove); + + itemsToRemove.Clear(); } }