Optimize memory usage

This commit is contained in:
JustArchi
2018-12-03 01:24:33 +01:00
parent 4582c40dbe
commit 555a74e2b6
3 changed files with 6 additions and 9 deletions

View File

@@ -275,10 +275,12 @@ namespace ArchiSteamFarm {
byte emptyMatches = 0;
HashSet<(uint AppID, Steam.Asset.EType Type)> skippedSetsThisRound = new HashSet<(uint AppID, Steam.Asset.EType Type)>();
foreach (ListedUser listedUser in listedUsers.Where(listedUser => listedUser.MatchEverything && listedUser.MatchableTypes.Any(acceptedMatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderByDescending(listedUser => listedUser.Score).Take(MaxMatchedBotsHard)) {
foreach (ListedUser listedUser in listedUsers.Where(listedUser => listedUser.MatchEverything && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderByDescending(listedUser => listedUser.Score).Take(MaxMatchedBotsHard)) {
Bot.ArchiLogger.LogGenericTrace(listedUser.SteamID + "...");
HashSet<Steam.Asset> theirInventory = await Bot.ArchiWebHandler.GetInventory(listedUser.SteamID, tradable: true, wantedTypes: acceptedMatchableTypes, skippedSets: skippedSetsThisRound).ConfigureAwait(false);
HashSet<Steam.Asset.EType> sharedTypes = acceptedMatchableTypes.Where(listedUser.MatchableTypes.Contains).ToHashSet();
HashSet<Steam.Asset> theirInventory = await Bot.ArchiWebHandler.GetInventory(listedUser.SteamID, tradable: true, wantedTypes: sharedTypes, skippedSets: skippedSetsThisRound).ConfigureAwait(false);
if ((theirInventory == null) || (theirInventory.Count == 0)) {
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(theirInventory)));
continue;