Match slices without materialising them when parsing - #382
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #382 +/- ##
=======================================
Coverage 98.01% 98.01%
=======================================
Files 39 39
Lines 52818 52821 +3
Branches 1105 1106 +1
=======================================
+ Hits 51770 51773 +3
Misses 795 795
Partials 253 253 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📊 Benchmark Results
PR branch
PR base
|
This was referenced Aug 14, 2026
Closed
Closed
This was referenced Aug 23, 2026
Closed
Closed
This was referenced Aug 31, 2026
Closed
Open
This was referenced Sep 1, 2026
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.
Two
Substringcalls on the parse path existed only to hand a slice to a regex:MaybeStripNationalPrefixAndCarrierCode—numberString.Substring(prefixMatch.Length)for anIsMatchAllcheckMaybeStripExtension—numberString.Substring(0, m.Index)for the viability checkOn net7.0+
Regex.IsMatch(ReadOnlySpan<char>)means neither slice needs to become a string. Bothcall sites now go through a small helper that holds the
#if, so the parse logic itself reads thesame as before — this file is kept diffable against the upstream Java.
The
PhoneRegexspan overload isinternal: a public one would exist on the net8.0 and net10.0assets but not netstandard2.0, which is what package validation's cross-framework check polices.
Replacing the public
stringoverloads outright is recorded on #375 for a major version.These are the paths #381 made measurable — an E164 parse never reaches either, since both regexes
fail and cost nothing. Watch
ParseNationalFormatandParseWithExtensionallocation.