Various optimisations to Markup instantiation & formatting#2008
Merged
patriksvensson merged 11 commits intospectreconsole:mainfrom Feb 25, 2026
Merged
Various optimisations to Markup instantiation & formatting#2008patriksvensson merged 11 commits intospectreconsole:mainfrom
patriksvensson merged 11 commits intospectreconsole:mainfrom
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
|
Sorry for not getting back to you sooner about this PR. The results are very promising, but the PR needs to be rebased against upstream and have the merge conflicts resolved. I can do this for you, but it will take a couple of days since I'm away on vacation. |
Contributor
Author
|
No problem, thanks for taking a look at it. I just held off on rebasing due to instructions in the contribution guidelines, so I'll get on that now. |
This will only allocate if an emoji replacement occurs. I think taking a span is pointless unless it'd be a TryReplace pattern or write to a span. As it was, it just forced a new string to be created in all circumstances.
patriksvensson
requested changes
Feb 23, 2026
src/Spectre.Console/Internal/Text/WhiteSpaceSegmentEnumerator.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrik Svensson <[email protected]>
patriksvensson
approved these changes
Feb 25, 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.
Somewhat related to #232
Changes
Added several benchmarks focused around the instantiation of the
Markuptype, since that's used all over the place when taking in strings. There's one overall benchmark (MarkupBenchmarks.Constructor) and every other benchmark I added is focused on a part of the logic called by the constructor at various levels. I did this mostly just to demonstrate the effects of individual changes. They're in separate commits, so feel free to just drop any benchmarks that aren't wanted.The actual changes are also in independent commits except for the last one concerning spans in
Paragraph.Append, which depends on the one before it. So again, feel free to drop any that are unwanted or that you'd want reworked heavily.Benchmarks
Here are benchmark runs for before and after (with some minor editing to make comparison easier). I ran them for .NET Framework 4.8.1 as well since .NET standard is still supported. Just to make sure there were no unexpected negative effects.
.NET 10
.NET Framework 4.8.1
Please upvote 👍 this pull request if you are interested in it.