refactor: use [GeneratedRegex] for SFC/DISM/speedtest literal patterns#852
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the three remaining literal-pattern
Regex.Matchcall sites tosource-generated
[GeneratedRegex]partial methods. The pattern strings areunchanged, so matching behavior is byte-identical —
[GeneratedRegex]just movescompilation from runtime to build time (no startup
Regexconstruction, noper-call interpreter overhead).
Changes
ViewModels/CleanupViewModel.csRegex.Match(l.Text, @"(\d+)\s*%")→SfcPercentRegex().Match(...)Regex.Match(l.Text, @"([\d.]+)%")→DismPercentRegex().Match(...)ViewModels/SpeedTestViewModel.csRegex.Match(option, @"ID:\s*(\d+)")→ServerIdRegex().Match(...)using System.Text.RegularExpressions;(was fully-qualified before).Not converted (deliberately)
LogServiceline 33 builds its regex from an interpolated pattern(
$@"(?i)({escaped})...") — a runtime value, so it cannot be source-generated.It stays a runtime
Regex. The constant fallback pattern there was alreadyconverted in the earlier
[GeneratedRegex]PR.Verification
sealed partial class— the prerequisite for[GeneratedRegex].Behavior identical (Protocol Q).
refactor:→ no release.