-
-
Notifications
You must be signed in to change notification settings - Fork 109
perf: remove unnecessary manual string.Replace code.
#4134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
Thanks! |
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.