From a658f0b9b6087ba917df22d870aaccf22c6b32b4 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 21 Apr 2018 22:10:34 +0200 Subject: [PATCH] Small optimization --- ArchiSteamFarm/Trading.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index f70b9340d..5e69cf8d9 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -89,14 +89,14 @@ namespace ArchiSteamFarm { Dictionary<(Steam.Asset.EType Type, uint AppID), List> itemAmountToGivePerGame = new Dictionary<(Steam.Asset.EType Type, uint AppID), List>(); Dictionary itemAmountsToGive = new Dictionary(itemAmounts); foreach (Steam.Asset item in itemsToGive) { - for (uint i = 0; i < item.Amount; i++) { - if (!itemAmountToGivePerGame.TryGetValue((item.Type, item.RealAppID), out List amountsToGive)) { - amountsToGive = new List(); - itemAmountToGivePerGame[(item.Type, item.RealAppID)] = amountsToGive; - } + if (!itemAmountToGivePerGame.TryGetValue((item.Type, item.RealAppID), out List amountsToGive)) { + amountsToGive = new List(); + itemAmountToGivePerGame[(item.Type, item.RealAppID)] = amountsToGive; + } + for (uint i = 0; i < item.Amount; i++) { amountsToGive.Add(itemAmountsToGive.TryGetValue(item.ClassID, out uint amount) ? amount : 0); - itemAmountsToGive[item.ClassID] = amount - 1; // We're giving one, so we have one less + itemAmountsToGive[item.ClassID] = --amount; // We're giving one, so we have one less } } @@ -109,12 +109,12 @@ namespace ArchiSteamFarm { Dictionary<(Steam.Asset.EType Type, uint AppID), List> itemAmountToReceivePerGame = new Dictionary<(Steam.Asset.EType Type, uint AppID), List>(); Dictionary itemAmountsToReceive = new Dictionary(itemAmounts); foreach (Steam.Asset item in itemsToReceive) { - for (uint i = 0; i < item.Amount; i++) { - if (!itemAmountToReceivePerGame.TryGetValue((item.Type, item.RealAppID), out List amountsToReceive)) { - amountsToReceive = new List(); - itemAmountToReceivePerGame[(item.Type, item.RealAppID)] = amountsToReceive; - } + if (!itemAmountToReceivePerGame.TryGetValue((item.Type, item.RealAppID), out List amountsToReceive)) { + amountsToReceive = new List(); + itemAmountToReceivePerGame[(item.Type, item.RealAppID)] = amountsToReceive; + } + for (uint i = 0; i < item.Amount; i++) { amountsToReceive.Add(itemAmountsToReceive.TryGetValue(item.ClassID, out uint amount) ? amount : 0); itemAmountsToReceive[item.ClassID] = ++amount; // We're getting one, so we have one more }