diff options
| author | Andrey Sukharev <SukharevAndrey@users.noreply.github.com> | 2022-12-04 03:43:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-04 00:43:23 +0000 |
| commit | 3868a0020611491e30db19e5b27d33a7559c7071 (patch) | |
| tree | 4bb5bce15a9a4e37f111c5d53b0909cc92a3b4f7 /Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs | |
| parent | 933e5144a975b324298d50032ec3fcce47a5fbf3 (diff) | |
Use source generated regular expressions (#4005)
Diffstat (limited to 'Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs')
| -rw-r--r-- | Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs b/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs index d3c0d1bf..d695449b 100644 --- a/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs +++ b/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs @@ -9,7 +9,7 @@ using System.Text.RegularExpressions; namespace Ryujinx.HLE.Loaders.Executables { - class NsoExecutable : IExecutable + partial class NsoExecutable : IExecutable { public byte[] Program { get; } public Span<byte> Text => Program.AsSpan((int)TextOffset, (int)TextSize); @@ -29,6 +29,13 @@ namespace Ryujinx.HLE.Loaders.Executables public string Name; public Array32<byte> BuildId; + [GeneratedRegex(@"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] + private static partial Regex ModuleRegex(); + [GeneratedRegex(@"sdk_version: ([0-9.]*)")] + private static partial Regex FsSdkRegex(); + [GeneratedRegex(@"SDK MW[ -~]*")] + private static partial Regex SdkMwRegex(); + public NsoExecutable(IStorage inStorage, string name = null) { NsoReader reader = new NsoReader(); @@ -83,7 +90,7 @@ namespace Ryujinx.HLE.Loaders.Executables if (string.IsNullOrEmpty(modulePath)) { - Match moduleMatch = Regex.Match(rawTextBuffer, @"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); + Match moduleMatch = ModuleRegex().Match(rawTextBuffer); if (moduleMatch.Success) { modulePath = moduleMatch.Value; @@ -92,13 +99,13 @@ namespace Ryujinx.HLE.Loaders.Executables stringBuilder.AppendLine($" Module: {modulePath}"); - Match fsSdkMatch = Regex.Match(rawTextBuffer, @"sdk_version: ([0-9.]*)", RegexOptions.Compiled); + Match fsSdkMatch = FsSdkRegex().Match(rawTextBuffer); if (fsSdkMatch.Success) { stringBuilder.AppendLine($" FS SDK Version: {fsSdkMatch.Value.Replace("sdk_version: ", "")}"); } - MatchCollection sdkMwMatches = Regex.Matches(rawTextBuffer, @"SDK MW[ -~]*", RegexOptions.Compiled); + MatchCollection sdkMwMatches = SdkMwRegex().Matches(rawTextBuffer); if (sdkMwMatches.Count != 0) { string libHeader = " SDK Libraries: "; |
