From 07c354f9e753e356be6fa4d9f3dd7b5e28ebc4cd Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 25 May 2022 20:04:54 +0200 Subject: [PATCH] Commit the most misc optimization in history I found it accidentally, lol --- ArchiSteamFarm/Steam/Exchange/Trading.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/Steam/Exchange/Trading.cs b/ArchiSteamFarm/Steam/Exchange/Trading.cs index 15af743cc..36ddffefa 100644 --- a/ArchiSteamFarm/Steam/Exchange/Trading.cs +++ b/ArchiSteamFarm/Steam/Exchange/Trading.cs @@ -196,7 +196,8 @@ public sealed class Trading : IDisposable { // Neutrality can't reach value below 0 at any single point of calculation, as that would imply a loss of progress even if we'd end up with a positive value by the end int neutrality = 0; - for (byte i = 0; i < afterAmounts.Count; i++) { + // Skip initial 0 index, as we already checked it above and it doesn't change neutrality from 0 + for (byte i = 1; i < afterAmounts.Count; i++) { // We assume that the difference between amounts will be within int range, therefore we accept underflow here (for subtraction), and since we cast that result to int afterwards, we also accept overflow for the cast itself neutrality += unchecked((int) (afterAmounts[i] - beforeAmounts[i]));