Perf: remove Regex in zip entry lookup and move I/O outside lock in geocoder#314
Draft
Perf: remove Regex in zip entry lookup and move I/O outside lock in geocoder#314
Conversation
…eocoder Co-authored-by: wmundev <30316250+wmundev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify and suggest improvements for inefficient code
Perf: remove Regex in zip entry lookup and move I/O outside lock in geocoder
Feb 28, 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 inefficiencies in
PhoneNumberOfflineGeocoder— one creating unnecessary Regex objects per zip entry comparison, another holding a lock across slow file I/O.Changes
Replace
Regex.Replacewith string ops inGetManifestZipFileStream: the staticRegex.Replacecall internally constructs aRegexobject on every zip entry during each geocoding lookup. Replaced withstring.Replace(char, char)— no allocation, no compilation overhead.Move file I/O outside the lock in
GetPhonePrefixDescriptions: previously theavailablePhonePrefixMapslock was held for the full duration of zip decompression + parsing, serializing all threads behind a single load. Changed to double-check locking: cache lookup under lock → load without lock → store under lock. Concurrent requests for different locales no longer block each other.Removed unused
using System.Text.RegularExpressionsfollowing the Regex removal.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.