[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

@@ -290,8 +290,8 @@ public sealed partial class A2R
string[] metaFields = metaData.Split('\n');
foreach(string[] keyValue in metaFields.Select(field => field.Split('\t'))
.Where(keyValue => keyValue.Length == 2))
foreach(string[] keyValue in metaFields.Select(static field => field.Split('\t'))
.Where(static keyValue => keyValue.Length == 2))
_meta.Add(keyValue[0], keyValue[1]);
if(_meta.TryGetValue("image_date", out string imageDate))

View File

@@ -14,6 +14,16 @@ namespace Aaru.Images;
public sealed partial class AaruFormat
{
// AARU_EXPORT int32_t AARU_CALL aaruf_set_dumphw(void *context, uint8_t *data, size_t length)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_set_dumphw", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_set_dumphw(IntPtr context, [In] byte[] data, nuint length);
// AARU_EXPORT int32_t AARU_CALL aaruf_get_dumphw(void *context, uint8_t *buffer, size_t *length)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_get_dumphw", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_get_dumphw(IntPtr context, byte[] buffer, ref nuint length);
#region IWritableOpticalImage Members
/// <inheritdoc />
@@ -283,7 +293,7 @@ public sealed partial class AaruFormat
});
}
dump.Extents = dump.Extents.OrderBy(t => t.Start).ToList();
dump.Extents = dump.Extents.OrderBy(static t => t.Start).ToList();
if(dump.Extents.Count > 0) dumpHardware.Add(dump);
}
@@ -295,14 +305,4 @@ public sealed partial class AaruFormat
}
#endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_set_dumphw(void *context, uint8_t *data, size_t length)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_set_dumphw", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_set_dumphw(IntPtr context, [In] byte[] data, nuint length);
// AARU_EXPORT int32_t AARU_CALL aaruf_get_dumphw(void *context, uint8_t *buffer, size_t *length)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_get_dumphw", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_get_dumphw(IntPtr context, byte[] buffer, ref nuint length);
}

View File

@@ -113,7 +113,7 @@ public sealed partial class AaruFormat
if(_tracks is null) return _tracks;
foreach(Track track in Tracks.OrderBy(t => t.StartSector))
foreach(Track track in Tracks.OrderBy(static t => t.StartSector))
{
switch(track.Sequence)
{
@@ -123,7 +123,7 @@ public sealed partial class AaruFormat
track.Indexes[1] = (int)track.StartSector;
continue;
case 1 when Tracks.All(t => t.Sequence != 0):
case 1 when Tracks.All(static t => t.Sequence != 0):
track.Pregap = 150;
track.Indexes[0] = -150;
track.Indexes[1] = (int)track.StartSector;
@@ -171,7 +171,7 @@ public sealed partial class AaruFormat
List<Session> sessions = [];
for(var i = 1; i <= Tracks.Max(t => t.Session); i++)
for(var i = 1; i <= Tracks.Max(static t => t.Session); i++)
{
sessions.Add(new Session
{

View File

@@ -77,7 +77,7 @@ public sealed partial class AaruFormat
ulong currentTrackOffset = 0;
List<Partition> partitions = [];
foreach(Track track in Tracks.OrderBy(t => t.StartSector))
foreach(Track track in Tracks.OrderBy(static t => t.StartSector))
{
partitions.Add(new Partition
{

View File

@@ -190,7 +190,7 @@ public sealed partial class AaruFormat
{
// Convert options dictionary to string format
string optionsString = options is { Count: > 0 }
? string.Join(";", options.Select(kvp => $"{kvp.Key}={kvp.Value}"))
? string.Join(";", options.Select(static kvp => $"{kvp.Key}={kvp.Value}"))
: null;
// Create new image
@@ -288,8 +288,9 @@ public sealed partial class AaruFormat
// Convert array of booleans to List of enums
for(nuint i = 0; i < sizet_length; i++)
if(sectorTagsBuffer[i] != 0)
_imageInfo.ReadableSectorTags.Add((SectorTagType)i);
{
if(sectorTagsBuffer[i] != 0) _imageInfo.ReadableSectorTags.Add((SectorTagType)i);
}
sizet_length = 0;
ret = aaruf_get_readable_media_tags(_context, null, ref sizet_length);
@@ -313,8 +314,9 @@ public sealed partial class AaruFormat
// Convert array of booleans to List of enums
for(nuint i = 0; i < sizet_length; i++)
if(mediaTagsBuffer[i] != 0)
_imageInfo.ReadableMediaTags.Add((MediaTagType)i);
{
if(mediaTagsBuffer[i] != 0) _imageInfo.ReadableMediaTags.Add((MediaTagType)i);
}
ret = aaruf_get_media_sequence(_context, out int sequence, out int lastSequence);

View File

@@ -482,7 +482,7 @@ public sealed partial class Alcohol120
if(!_isDvd)
{
CommonTypes.Structs.Track[] tmpTracks = tracks.OrderBy(t => t.Sequence).ToArray();
CommonTypes.Structs.Track[] tmpTracks = tracks.OrderBy(static t => t.Sequence).ToArray();
for(var i = 1; i < tmpTracks.Length; i++)
{
@@ -506,7 +506,7 @@ public sealed partial class Alcohol120
tracks = tmpTracks.ToList();
}
foreach(CommonTypes.Structs.Track track in tracks.OrderBy(t => t.Sequence))
foreach(CommonTypes.Structs.Track track in tracks.OrderBy(static t => t.Sequence))
{
uint subchannelSize;
@@ -550,7 +550,7 @@ public sealed partial class Alcohol120
byte sessions = byte.MinValue;
foreach(CommonTypes.Structs.Track t in _writingTracks.Where(t => t.Session > byte.MinValue))
foreach(CommonTypes.Structs.Track t in _writingTracks.Where(static t => t.Session > byte.MinValue))
sessions = (byte)t.Session;
var header = new Header
@@ -573,7 +573,7 @@ public sealed partial class Alcohol120
_alcSessions = new Dictionary<int, Session>();
_alcTracks = new Dictionary<int, Track>();
_alcToc = new Dictionary<int, Dictionary<int, Track>>();
_writingTracks = _writingTracks.OrderBy(t => t.Session).ThenBy(t => t.Sequence).ToList();
_writingTracks = _writingTracks.OrderBy(static t => t.Session).ThenBy(static t => t.Sequence).ToList();
_alcTrackExtras = new Dictionary<int, TrackExtra>();
long currentTrackOffset = header.sessionOffset + Marshal.SizeOf<Session>() * sessions;
@@ -740,10 +740,10 @@ public sealed partial class Alcohol120
unknown2 = new byte[24],
psec = (byte)(_imageInfo.MediaType == MediaType.CDI
? 0x10
: _writingTracks.Any(t => t.Type is TrackType
.CdMode2Form1
or TrackType.CdMode2Form2
or TrackType.CdMode2Formless)
: _writingTracks.Any(static t =>
t.Type is TrackType.CdMode2Form1
or TrackType.CdMode2Form2
or TrackType.CdMode2Formless)
? 0x20
: 0),
extraOffset = (uint)currentExtraOffset
@@ -781,7 +781,7 @@ public sealed partial class Alcohol120
}
foreach(CommonTypes.Structs.Track track in _writingTracks.Where(t => t.Session == i)
.OrderBy(t => t.Sequence))
.OrderBy(static t => t.Sequence))
{
var alcTrk = new Track();
@@ -911,7 +911,10 @@ public sealed partial class Alcohol120
LbaToMsf(_writingTracks.First(t => t.Session == i + 1).StartSector - 150);
(byte minute, byte second, byte frame) leadoutPmsf =
LbaToMsf(_writingTracks.OrderBy(t => t.Session).ThenBy(t => t.Sequence).Last().StartSector);
LbaToMsf(_writingTracks.OrderBy(static t => t.Session)
.ThenBy(static t => t.Sequence)
.Last()
.StartSector);
thisSessionTracks.Add(0xB0,
new Track

View File

@@ -744,9 +744,10 @@ public sealed partial class BlindWrite4
}
// As long as subchannel is written for any track, it is present for all tracks
if(Tracks.Any(t => t.SubchannelType == TrackSubchannelType.Packed))
foreach(Track track in Tracks)
track.SubchannelType = TrackSubchannelType.Packed;
if(Tracks.Any(static t => t.SubchannelType == TrackSubchannelType.Packed))
{
foreach(Track track in Tracks) track.SubchannelType = TrackSubchannelType.Packed;
}
_imageInfo.MediaType = MediaType.CD;

View File

@@ -840,10 +840,11 @@ public sealed partial class BlindWrite5
.ToList();
if(fileCharsForThisTrack.Count == 0 &&
_filePaths.Any(f => Path.GetExtension(f.FilePath).ToLowerInvariant() == ".b00"))
_filePaths.Any(static f => Path.GetExtension(f.FilePath).ToLowerInvariant() == ".b00"))
{
DataFileCharacteristics splitStartChars =
_filePaths.FirstOrDefault(f => Path.GetExtension(f.FilePath).ToLowerInvariant() == ".b00");
_filePaths.FirstOrDefault(static f => Path.GetExtension(f.FilePath).ToLowerInvariant() ==
".b00");
string filename = Path.GetFileNameWithoutExtension(splitStartChars.FilePath);
var lowerCaseExtension = false;

View File

@@ -84,8 +84,8 @@ public sealed partial class Cdrdao
{
get
{
Track firstTrack = Tracks.First(t => t.Sequence == Tracks.Min(m => m.Sequence));
Track lastTrack = Tracks.First(t => t.Sequence == Tracks.Max(m => m.Sequence));
Track firstTrack = Tracks.First(t => t.Sequence == Tracks.Min(static m => m.Sequence));
Track lastTrack = Tracks.First(t => t.Sequence == Tracks.Max(static m => m.Sequence));
return
[
@@ -160,13 +160,13 @@ public sealed partial class Cdrdao
{
aaruTrack.Indexes[0] = -150;
foreach(KeyValuePair<int, ulong> idx in cdrTrack.Indexes.OrderBy(i => i.Key))
foreach(KeyValuePair<int, ulong> idx in cdrTrack.Indexes.OrderBy(static i => i.Key))
aaruTrack.Indexes[(ushort)idx.Key] = (int)idx.Value;
}
}
else
{
foreach(KeyValuePair<int, ulong> idx in cdrTrack.Indexes.OrderBy(i => i.Key))
foreach(KeyValuePair<int, ulong> idx in cdrTrack.Indexes.OrderBy(static i => i.Key))
aaruTrack.Indexes[(ushort)idx.Key] = (int)idx.Value;
}

View File

@@ -501,14 +501,13 @@ public sealed partial class Cdrdao
}
if(_writingTracks != null && _writingStreams != null)
{
foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close();
}
foreach(FileStream oldTrack in _writingStreams.Select(static t => t.Value).Distinct())
oldTrack.Close();
ulong currentOffset = 0;
_writingTracks = [];
foreach(Track track in tracks.OrderBy(t => t.Sequence))
foreach(Track track in tracks.OrderBy(static t => t.Sequence))
{
if(track.SubchannelType is TrackSubchannelType.Q16 or TrackSubchannelType.Q16Interleaved)
{
@@ -582,12 +581,12 @@ public sealed partial class Cdrdao
_writingStreams.First().Value.Close();
}
bool data = _writingTracks.Count(t => t.Type != TrackType.Audio) > 0;
bool data = _writingTracks.Count(static t => t.Type != TrackType.Audio) > 0;
bool mode2 =
_writingTracks.Count(t => t.Type is TrackType.CdMode2Form1
or TrackType.CdMode2Form2
or TrackType.CdMode2Formless) >
_writingTracks.Count(static t => t.Type is TrackType.CdMode2Form1
or TrackType.CdMode2Form2
or TrackType.CdMode2Formless) >
0;
if(mode2)
@@ -654,7 +653,8 @@ public sealed partial class Cdrdao
(ulong)(track.RawBytesPerSector +
(track.SubchannelType != TrackSubchannelType.None ? 96 : 0)));
foreach(KeyValuePair<ushort, int> index in track.Indexes.OrderBy(i => i.Key).Where(i => i.Key > 1))
foreach(KeyValuePair<ushort, int> index in track.Indexes.OrderBy(static i => i.Key)
.Where(static i => i.Key > 1))
{
msf = LbaToMsf((ulong)index.Value - (track.Pregap + track.StartSector));

View File

@@ -346,7 +346,7 @@ public sealed partial class CdrWin
Start = extentStart,
End = extentEnd
}
}.OrderBy(e => e.Start)
}.OrderBy(static e => e.Start)
.ToList();
}
}
@@ -1021,7 +1021,7 @@ public sealed partial class CdrWin
else
sessions[s - 1].EndSector = sessions[s - 1].StartSector + sessionSectors - 1;
CdrWinTrack firstSessionTrack = cueTracks.OrderBy(t => t.Sequence).First(t => t.Session == s);
CdrWinTrack firstSessionTrack = cueTracks.OrderBy(static t => t.Sequence).First(t => t.Session == s);
firstSessionTrack.Indexes.TryGetValue(0, out firstSessionTrack.Pregap);
@@ -1364,7 +1364,7 @@ public sealed partial class CdrWin
for(var s = 1; s <= sessions.Length; s++) _discImage.Sessions.Add(sessions[s - 1]);
_imageInfo.Sectors = _discImage.Sessions.MaxBy(s => s.EndSector).EndSector + 1;
_imageInfo.Sectors = _discImage.Sessions.MaxBy(static s => s.EndSector).EndSector + 1;
AaruLogging.Debug(MODULE_NAME, Localization.Session_information);
@@ -1613,7 +1613,7 @@ public sealed partial class CdrWin
return ErrorNumber.InvalidArgument;
}
if(_discImage.Tracks.All(t => t.Isrc == null))
if(_discImage.Tracks.All(static t => t.Isrc == null))
_imageInfo.ReadableSectorTags.Remove(SectorTagType.CdTrackIsrc);
if(_isCd) return ErrorNumber.NoError;
@@ -1997,7 +1997,7 @@ public sealed partial class CdrWin
case CDRWIN_TRACK_TYPE_MODE2_FORM2:
if(tag != SectorTagType.CdSectorSubchannel ||
!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel) ||
_discImage.Tracks.All(t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
_discImage.Tracks.All(static t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
return ErrorNumber.NoData;
buffer = new byte[length * 96];
@@ -2017,7 +2017,7 @@ public sealed partial class CdrWin
case SectorTagType.CdSectorEccQ:
if(tag != SectorTagType.CdSectorSubchannel ||
!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel) ||
_discImage.Tracks.All(t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
_discImage.Tracks.All(static t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
return ErrorNumber.NotSupported;
buffer = new byte[length * 96];
@@ -2070,7 +2070,7 @@ public sealed partial class CdrWin
case SectorTagType.CdSectorSubHeader:
if(tag != SectorTagType.CdSectorSubchannel ||
!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel) ||
_discImage.Tracks.All(t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
_discImage.Tracks.All(static t => t.TrackType != CDRWIN_TRACK_TYPE_CDG))
return ErrorNumber.NotSupported;
buffer = new byte[length * 96];
@@ -2455,7 +2455,7 @@ public sealed partial class CdrWin
/// <inheritdoc />
public List<Track> GetSessionTracks(ushort session) =>
Tracks.Where(t => t.Session == session).OrderBy(t => t.Sequence).ToList();
Tracks.Where(t => t.Session == session).OrderBy(static t => t.Sequence).ToList();
#endregion
}

View File

@@ -56,8 +56,8 @@ public sealed partial class CdrWin
long readBytes;
byte[] verifyBytes;
IFilter[] filters = _discImage.Tracks.OrderBy(t => t.Sequence)
.Select(t => t.TrackFile.DataFilter)
IFilter[] filters = _discImage.Tracks.OrderBy(static t => t.Sequence)
.Select(static t => t.TrackFile.DataFilter)
.Distinct()
.ToArray();
@@ -65,7 +65,7 @@ public sealed partial class CdrWin
{
var ctx = new Sha1Context();
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
foreach(Stream stream in filters.Select(static filter => filter.GetDataForkStream()))
{
readBytes = 0;
verifyBytes = new byte[verifySize];
@@ -93,7 +93,7 @@ public sealed partial class CdrWin
{
var ctx = new Md5Context();
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
foreach(Stream stream in filters.Select(static filter => filter.GetDataForkStream()))
{
readBytes = 0;
verifyBytes = new byte[verifySize];
@@ -121,7 +121,7 @@ public sealed partial class CdrWin
{
var ctx = new Crc32Context();
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
foreach(Stream stream in filters.Select(static filter => filter.GetDataForkStream()))
{
readBytes = 0;
verifyBytes = new byte[verifySize];

View File

@@ -436,13 +436,12 @@ public sealed partial class CdrWin
}
if(_writingTracks != null && _writingStreams != null)
{
foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close();
}
foreach(FileStream oldTrack in _writingStreams.Select(static t => t.Value).Distinct())
oldTrack.Close();
_writingTracks = [];
foreach(Track track in tracks.OrderBy(t => t.Sequence))
foreach(Track track in tracks.OrderBy(static t => t.Sequence))
{
track.File = _separateTracksWriting
? _writingBaseName + $"_track{track.Sequence:D2}.bin"
@@ -530,7 +529,7 @@ public sealed partial class CdrWin
if(DumpHardware != null)
{
foreach(var dumpData in from dump in DumpHardware
from extent in dump.Extents.OrderBy(e => e.Start)
from extent in dump.Extents.OrderBy(static e => e.Start)
select new
{
dump.Manufacturer,
@@ -608,7 +607,7 @@ public sealed partial class CdrWin
if(track.Pregap > 0 && _isCd)
{
if(track.Sequence > _writingTracks.Where(t => t.Session == track.Session).Min(t => t.Sequence))
if(track.Sequence > _writingTracks.Where(t => t.Session == track.Session).Min(static t => t.Sequence))
{
_descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}",
0,
@@ -636,7 +635,7 @@ public sealed partial class CdrWin
if(_isCd)
{
foreach(KeyValuePair<ushort, int> index in track.Indexes.Where(i => i.Key > 1))
foreach(KeyValuePair<ushort, int> index in track.Indexes.Where(static i => i.Key > 1))
{
msf = LbaToMsf((ulong)index.Value);
@@ -648,11 +647,12 @@ public sealed partial class CdrWin
}
}
ushort lastSession = _writingTracks.Max(t => t.Session);
ushort lastSession = _writingTracks.Max(static t => t.Session);
if(currentSession >= lastSession) continue;
Track lastTrackInSession = _writingTracks.Where(t => t.Session == currentSession).MaxBy(t => t.Sequence);
Track lastTrackInSession =
_writingTracks.Where(t => t.Session == currentSession).MaxBy(static t => t.Sequence);
if(track.Sequence != lastTrackInSession.Sequence) continue;

View File

@@ -63,9 +63,8 @@ public sealed partial class Cpcdsk
int pos;
for(pos = 0; pos < 254; pos++)
{
if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break;
}
if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A)
break;
if(pos >= 254) return ErrorNumber.InvalidArgument;
@@ -270,7 +269,7 @@ public sealed partial class Cpcdsk
thisTrackAddressMarks[(trackInfo.sectorsInfo[k - 1].id & 0x3F) - 1] = addressMark;
}
foreach(KeyValuePair<int, byte[]> s in thisTrackSectors.OrderBy(k => k.Key))
foreach(KeyValuePair<int, byte[]> s in thisTrackSectors.OrderBy(static k => k.Key))
{
_sectors.Add(currentSector, s.Value);
_addressMarks.Add(currentSector, s.Value);

View File

@@ -569,7 +569,7 @@ public sealed partial class CloneCd
Tracks.Add(currentTrack);
}
Track[] tmpTracks = Tracks.OrderBy(t => t.Sequence).ToArray();
Track[] tmpTracks = Tracks.OrderBy(static t => t.Sequence).ToArray();
ulong currentDataOffset = 0;
ulong currentSubchannelOffset = 0;
@@ -616,8 +616,8 @@ public sealed partial class CloneCd
if(trackIndexes.TryGetValue((byte)tmpTrack.Sequence, out Dictionary<byte, int> indexes))
{
foreach((byte index, int value) in indexes.OrderBy(i => i.Key)
.Where(trackIndex => trackIndex.Key > 1))
foreach((byte index, int value) in indexes.OrderBy(static i => i.Key)
.Where(static trackIndex => trackIndex.Key > 1))
// Untested as of 20210711
tmpTrack.Indexes[index] = value;
@@ -956,15 +956,15 @@ public sealed partial class CloneCd
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap.Where(kvp => sectorAddress >= kvp.Value)
.SelectMany(_ => Tracks,
(kvp, track) => new
static (kvp, track) => new
{
kvp,
track
})
.Where(t => t.track.Sequence == t.kvp.Key)
.Where(static t => t.track.Sequence == t.kvp.Key)
.Where(t => sectorAddress - t.kvp.Value <
t.track.EndSector - t.track.StartSector + 1)
.Select(t => t.kvp))
.Select(static t => t.kvp))
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return ErrorNumber.SectorNotFound;

View File

@@ -285,7 +285,7 @@ public sealed partial class CloneCd
Tracks = [];
foreach(Track track in tracks.OrderBy(t => t.Sequence))
foreach(Track track in tracks.OrderBy(static t => t.Sequence))
{
Track newTrack = track;

View File

@@ -171,7 +171,7 @@ public sealed partial class Gdi
{
sessions[s].Sequence = 1;
foreach(GdiTrack trk in _discImage.Tracks.Where(trk => !trk.HighDensity))
foreach(GdiTrack trk in _discImage.Tracks.Where(static trk => !trk.HighDensity))
{
if(sessions[s].StartTrack == 0)
sessions[s].StartTrack = trk.Sequence;
@@ -189,7 +189,7 @@ public sealed partial class Gdi
{
sessions[s].Sequence = 2;
foreach(GdiTrack trk in _discImage.Tracks.Where(trk => trk.HighDensity))
foreach(GdiTrack trk in _discImage.Tracks.Where(static trk => trk.HighDensity))
{
if(sessions[s].StartTrack == 0)
sessions[s].StartTrack = trk.Sequence;
@@ -305,8 +305,8 @@ public sealed partial class Gdi
_imageInfo.SectorSize = 2352; // All others
foreach(GdiTrack unused in
_discImage.Tracks.Where(track => (track.Flags & 0x4) == 0x4 && track.Bps == 2352))
foreach(GdiTrack unused in _discImage.Tracks.Where(static track =>
(track.Flags & 0x4) == 0x4 && track.Bps == 2352))
{
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);

View File

@@ -176,7 +176,8 @@ public sealed partial class KryoFlux
DateTime blockTime = DateTime.Now;
var foundDate = false;
foreach(string[] kvp in lines.Select(line => line.Split('=')).Where(kvp => kvp.Length == 2))
foreach(string[] kvp in lines.Select(static line => line.Split('='))
.Where(static kvp => kvp.Length == 2))
{
kvp[0] = kvp[0].Trim();
kvp[1] = kvp[1].Trim();

View File

@@ -1001,7 +1001,7 @@ public sealed partial class Nero
if(_cuesheetV1?.Entries?.Count > 0)
{
foreach(CueEntryV1 entry in _cuesheetV1.Entries.Where(e => e.TrackNumber == neroTrack.Sequence)
.OrderBy(e => e.IndexNumber))
.OrderBy(static e => e.IndexNumber))
{
track.Indexes[entry.IndexNumber] =
entry.Minute * 60 * 75 + entry.Second * 75 + entry.Frame - 150;
@@ -1012,7 +1012,7 @@ public sealed partial class Nero
else if(_cuesheetV2?.Entries?.Count > 0)
{
foreach(CueEntryV2 entry in _cuesheetV2.Entries.Where(e => e.TrackNumber == neroTrack.Sequence)
.OrderBy(e => e.IndexNumber))
.OrderBy(static e => e.IndexNumber))
{
track.Indexes[entry.IndexNumber] = entry.LbaStart;
_trackFlags[entry.TrackNumber] = (byte)((entry.Mode & 0xF0) >> 4);
@@ -1430,7 +1430,7 @@ public sealed partial class Nero
Tracks.Count > 0xF &&
moreTracksThanSessionTracks &&
onlyOneSession &&
Tracks.Any(t => t.Session > 0))
Tracks.Any(static t => t.Session > 0))
{
foreach(Track track in Tracks) track.Session = 1;

View File

@@ -39,7 +39,7 @@ public sealed partial class Vhd
{
static uint VhdChecksum(IEnumerable<byte> data)
{
uint checksum = data.Aggregate<byte, uint>(0, (current, b) => current + b);
uint checksum = data.Aggregate<byte, uint>(0, static (current, b) => current + b);
return ~checksum;
}

View File

@@ -169,8 +169,8 @@ public sealed partial class ZZZRawImage
/// <inheritdoc />
public IEnumerable<MediaTagType> SupportedMediaTags => _readWriteSidecars.Concat(_writeOnlySidecars)
.OrderBy(t => t.tag)
.Select(t => t.tag)
.OrderBy(static t => t.tag)
.Select(static t => t.tag)
.ToArray();
/// <inheritdoc />

View File

@@ -293,7 +293,7 @@ public sealed partial class ZZZRawImage
{
string suffix = _readWriteSidecars.Concat(_writeOnlySidecars)
.Where(t => t.tag == tag.Key)
.Select(t => t.name)
.Select(static t => t.name)
.FirstOrDefault();
if(suffix == null) continue;