[Refactor] Use static lambdas in LINQ queries for improved performance

This commit is contained in:
2025-11-24 03:00:06 +00:00
parent 5fe7f574d6
commit 04c45e69fa
126 changed files with 971 additions and 929 deletions

View File

@@ -194,7 +194,7 @@ public sealed class Acorn : IPartition
IcsTable table = Marshal.ByteArrayToStructureLittleEndian<IcsTable>(sector);
foreach(IcsEntry entry in table.entries.Where(entry => entry.size != 0))
foreach(IcsEntry entry in table.entries.Where(static entry => entry.size != 0))
{
// FileCore partition
Partition part;

View File

@@ -110,7 +110,7 @@ public sealed class DEC : IPartition
Sequence = counter,
Scheme = Name
})
.Where(part => part.Size > 0))
.Where(static part => part.Size > 0))
{
partitions.Add(part);
counter++;

View File

@@ -186,8 +186,8 @@ public sealed class GuidPartitionTable : IPartition
ulong pSeq = 0;
foreach(Entry entry in entries.Where(entry => entry.partitionType != Guid.Empty &&
entry.partitionId != Guid.Empty))
foreach(Entry entry in entries.Where(static entry => entry.partitionType != Guid.Empty &&
entry.partitionId != Guid.Empty))
{
AaruLogging.Debug(MODULE_NAME, "entry.partitionType = {0}", entry.partitionType);
AaruLogging.Debug(MODULE_NAME, "entry.partitionId = {0}", entry.partitionId);

View File

@@ -74,9 +74,9 @@ public sealed class Plan9 : IPartition
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
string[] really = StringHandlers.CToString(sector).Split('\n');
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part[..5] == "part ")
.Select(part => part.Split(' '))
.TakeWhile(tokens => tokens.Length == 4))
foreach(string[] tokens in really.TakeWhile(static part => part.Length >= 5 && part[..5] == "part ")
.Select(static part => part.Split(' '))
.TakeWhile(static tokens => tokens.Length == 4))
{
if(!ulong.TryParse(tokens[2], out ulong start) || !ulong.TryParse(tokens[3], out ulong end)) break;