Strip the national prefix without materialising a match - #385
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #385 +/- ##
==========================================
- Coverage 98.01% 98.01% -0.01%
==========================================
Files 39 39
Lines 52822 52842 +20
Branches 1106 1115 +9
==========================================
+ Hits 51774 51793 +19
Misses 795 795
- Partials 253 254 +1 ☔ 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
Closed
This was referenced Sep 1, 2026
Closed
Open
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.
ParseNationalFormatstill carries ~215 B over a plain E164 parse, and that residue is theMatchobject itself — #384 removed the group accesses around it but the match remained.
Whether the groups are needed is knowable before matching: only a transform rule or a requested
carrier code reads them, and after #384 a plain
Parserequests neither. Without them, the onlything this method uses is the prefix length.
So there is now a fast path that never materialises a
Match:matches itself, so the length is known without running a regex at all. Many regions are plain
0.Regex.EnumerateMatchesyields aValueMatchstruct withIndex/Lengthand allocates nothing.MatchBeginning.The slow path is untouched, so a transform rule or a carrier request behaves exactly as before, and
the public
MaybeStripNationalPrefixAndCarrierCodeoverload still passescarrierCode != null.Watch
ParseNationalFormat;ParseOnlyandParseWithExtensionshould not move.