From 835611547f2e8eec44c26b4a4de72997f4c6c511 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 20 Feb 2021 23:49:05 +0100 Subject: [PATCH] Mist optimization No need to initialize assetIDs if inventory is empty. Also we know exact amount of items this way. --- ArchiSteamFarm/ArchiWebHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index d7c089bf6..04ba72d50 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -149,7 +149,7 @@ namespace ArchiSteamFarm { ulong startAssetID = 0; // We need to store asset IDs to make sure we won't get duplicate items - HashSet assetIDs = new(); + HashSet? assetIDs = null; while (true) { await ASF.InventorySemaphore.WaitAsync().ConfigureAwait(false); @@ -170,6 +170,8 @@ namespace ArchiSteamFarm { yield break; } + assetIDs ??= new HashSet((int) response.Content.TotalInventoryCount); + if ((response.Content.Assets.Count == 0) || (response.Content.Descriptions.Count == 0)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response.Content.Assets) + " || " + nameof(response.Content.Descriptions))); }