[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

@@ -40,10 +40,10 @@ public static partial class ArrayHelpers
/// <summary>Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20)</summary>
/// <param name="array">Array</param>
/// <returns>True if null or whitespace</returns>
public static bool ArrayIsNullOrWhiteSpace(byte[] array) => array?.All(b => b is 0x00 or 0x20) != false;
public static bool ArrayIsNullOrWhiteSpace(byte[] array) => array?.All(static b => b is 0x00 or 0x20) != false;
/// <summary>Checks if an array is null or filled with the NULL byte (0x00)</summary>
/// <param name="array">Array</param>
/// <returns>True if null</returns>
public static bool ArrayIsNullOrEmpty(byte[] array) => array?.All(b => b == 0x00) != false;
public static bool ArrayIsNullOrEmpty(byte[] array) => array?.All(static b => b == 0x00) != false;
}

View File

@@ -41,7 +41,7 @@ namespace Aaru.Helpers;
/// </summary>
public sealed class DirColorsParser
{
private static readonly Lazy<DirColorsParser> _instance = new(() => new DirColorsParser());
private static readonly Lazy<DirColorsParser> _instance = new(static () => new DirColorsParser());
private DirColorsParser()
{
@@ -83,13 +83,13 @@ public sealed class DirColorsParser
sgr = parts[1];
}
if(!pattern.StartsWith("DIR", StringComparison.OrdinalIgnoreCase) &&
pattern is not ['.', ..] &&
if(!pattern.StartsWith("DIR", StringComparison.OrdinalIgnoreCase) &&
pattern is not ['.', ..] &&
!pattern.StartsWith("NORM", StringComparison.OrdinalIgnoreCase))
continue; // ( DIR, FILE, LINK, EXECUTABLE, or SUID)
// Build ANSI escape sequence
string ansi = $"\e[{sgr}m";
var ansi = $"\e[{sgr}m";
string hex;
try