From 32d8cdfde8cdd2c43812a3fb301fd0fec8fcce9a Mon Sep 17 00:00:00 2001 From: SokyranTheDragon Date: Mon, 1 Apr 2024 18:20:01 +0200 Subject: [PATCH] Replace Enumerable.Count(list) with list.Count Minor change that should not really affect anything, as `Enumerable.Count()` would still end up calling `list.Count`: ```csharp switch (source) { // Skipped irrelevant code case ICollection sources: return sources.Count; // Skipped irrelevant code } ``` --- Source/Client/Networking/JoinData.cs | 2 +- Source/Client/Syncing/Worker/SyncWorkers.cs | 2 +- Source/Client/UI/IngameDebug.cs | 2 +- Source/Client/UI/MainMenuAnimation.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Client/Networking/JoinData.cs b/Source/Client/Networking/JoinData.cs index 226c2c5f..9797de8d 100644 --- a/Source/Client/Networking/JoinData.cs +++ b/Source/Client/Networking/JoinData.cs @@ -23,7 +23,7 @@ public static byte[] WriteServerData(bool writeConfigs) { var data = new ByteWriter(); - data.WriteInt32(activeModsSnapshot.Count()); + data.WriteInt32(activeModsSnapshot.Count); foreach (var m in activeModsSnapshot) { data.WriteString(m.PackageIdNonUnique); diff --git a/Source/Client/Syncing/Worker/SyncWorkers.cs b/Source/Client/Syncing/Worker/SyncWorkers.cs index 64602c29..1700acba 100644 --- a/Source/Client/Syncing/Worker/SyncWorkers.cs +++ b/Source/Client/Syncing/Worker/SyncWorkers.cs @@ -25,7 +25,7 @@ public class SyncWorkerEntry private List subclasses; private SyncWorkerEntry parent; - public int SyncWorkerCount => syncWorkers.Count(); + public int SyncWorkerCount => syncWorkers.Count; public SyncWorkerEntry(Type type, bool shouldConstruct = false) { diff --git a/Source/Client/UI/IngameDebug.cs b/Source/Client/UI/IngameDebug.cs index 908c6a40..c2f00fd2 100644 --- a/Source/Client/UI/IngameDebug.cs +++ b/Source/Client/UI/IngameDebug.cs @@ -50,7 +50,7 @@ internal static void DoDebugPrintout() $"{Find.IdeoManager.classicMode} {Multiplayer.game.sync.knownClientOpinions.Count} {Multiplayer.game.sync.knownClientOpinions.FirstOrDefault()?.startTick} {async.mapTicks} {TickPatch.serverFrozen} {TickPatch.frozenAt} "); text.Append( - $"z: {Find.CurrentMap.haulDestinationManager.AllHaulDestinationsListForReading.Count()} d: {Find.CurrentMap.designationManager.designationsByDef.Count} hc: {Find.CurrentMap.listerHaulables.ThingsPotentiallyNeedingHauling().Count}"); + $"z: {Find.CurrentMap.haulDestinationManager.AllHaulDestinationsListForReading.Count} d: {Find.CurrentMap.designationManager.designationsByDef.Count} hc: {Find.CurrentMap.listerHaulables.ThingsPotentiallyNeedingHauling().Count}"); if (Find.CurrentMap.ParentFaction != null) { diff --git a/Source/Client/UI/MainMenuAnimation.cs b/Source/Client/UI/MainMenuAnimation.cs index 7fa6d3f9..c1810c71 100644 --- a/Source/Client/UI/MainMenuAnimation.cs +++ b/Source/Client/UI/MainMenuAnimation.cs @@ -61,7 +61,7 @@ static void Prefix(UI_BackgroundMain __instance, Rect bgRect) newPulseTimer += Time.deltaTime; if (newPulseTimer > 1 / 12f) { - var edge = edges[rand.Next(edges.Count())]; + var edge = edges[rand.Next(edges.Count)]; var switchEndpoints = rand.NextDouble() < 0.5; pulses.Add(new Pulse(switchEndpoints ? edge.v2 : edge.v1, switchEndpoints ? edge.v1 : edge.v2) { starting = true }); newPulseTimer = 0; @@ -132,7 +132,7 @@ static Vert GetNewEnd(Pulse pulse) while (newEnd == null && attempts < 20) { - var randEdge = edges[rand.Next(edges.Count())]; + var randEdge = edges[rand.Next(edges.Count)]; var otherVert = randEdge.OtherVert(pulse.end); if (otherVert != null && otherVert != pulse.start && otherVert != pulse.end) newEnd = otherVert;