perf: remove unnecessary manual string.Replace code.#4134
Merged
thomhurst merged 1 commit intothomhurst:mainfrom Dec 22, 2025
Merged
perf: remove unnecessary manual string.Replace code.#4134thomhurst merged 1 commit intothomhurst:mainfrom
string.Replace code.#4134thomhurst merged 1 commit intothomhurst:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes a manual span-based string manipulation implementation in favor of using the built-in string.Replace method. The change simplifies code in ArgumentFormatter.FormatDefault where dots are replaced with middle dots (·) to prevent VS Test Explorer from misinterpreting them as namespace separators.
Key Changes:
- Removes the
#if NET8_0_OR_GREATERconditional compilation block with manualSpan<char>manipulation - Replaces it with a simple
str.Replace(".", "·")call that works across all target frameworks - Maintains the existing optimization that skips replacement when no dots are present
4e4839b to
0753f27
Compare
0753f27 to
566579d
Compare
Owner
|
Thanks! |
This was referenced Dec 22, 2025
Merged
Merged
This was referenced Feb 2, 2026
This was referenced Feb 9, 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.
Remove redundant manual
string.Replacecode.string.Replaceis almost certainly faster, doesn't allocate when there aren't any changes to thestring, usesstring.Create, usesVectorisedlookups to find targets and won't allocate an intermediary buffer when the input string is larger than 256 characters.Containscall isn't needed becausestring.Replacedoes the same thing and early returns with the originalstring.