Skip to content

Commit

Permalink
Replace Enumerable.Count(list) with list.Count
Browse files Browse the repository at this point in the history
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<TSource> sources:
        return sources.Count;
    // Skipped irrelevant code
}
```
  • Loading branch information
SokyranTheDragon committed Apr 1, 2024
1 parent 84cc383 commit 32d8cdf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/Client/Networking/JoinData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Syncing/Worker/SyncWorkers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SyncWorkerEntry
private List<SyncWorkerEntry> subclasses;
private SyncWorkerEntry parent;

public int SyncWorkerCount => syncWorkers.Count();
public int SyncWorkerCount => syncWorkers.Count;

public SyncWorkerEntry(Type type, bool shouldConstruct = false)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/UI/IngameDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Client/UI/MainMenuAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 32d8cdf

Please sign in to comment.