Repository navigation
Split and join text with no markup without the run builder and interleaved copies - #78
Merged
Merged
Conversation
…eaved copies Substring of a run-free text skips the run builder, Split counts its delimiters to size the result exactly, Join with one separator writes the parts straight into the result, and Concat no longer copies its parts. Results are unchanged; property tests compare each against the forms they replaced on plain and marked text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaoLzbDbE9CZBRWWkKM4Es
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.
Before: splitting a 100-item plain list on spaces took 8.7 µs and 28,336 B, and joining 100 items took 2.7 µs and 8,232 B. Every segment built a run list even with no runs to clip, and
Joincollected parts and separators into a list, copied it to an array, and copied the parts again inConcat.After: the same split takes 4.2 µs and 8,752 B (the result array plus one string and one
MarkupTextper item), and the join takes 1.6 µs and 656 B. Results are the same, runs included.How:
ExtractRangereturns a slice with the shared empty run array when the text has no runs.Splitcounts the delimiters first and fills an exactly sized array.Joinwith one separator writes the parts and separators straight into the result string and builds runs only if something has them.Concattakes its parts as a span without copying them. Text with runs still goes through the existing run code.Tests: CsCheck property tests (fixed seed, 5,000 samples each) compare
Split,Substring,ConcatandJoinagainst copies of the old code on plain and marked input, with empty items, delimiters at both ends, multi-character delimiters and delimiters inside grapheme clusters. An allocation test bounds the plain split and join. All 1,390 tests pass.The only observable difference:
Join(separator, null)now throwsArgumentNullExceptioninstead ofNullReferenceException.Patch bump (2.24.3) in CHANGELOG.md. SharpMUSH picks it up with a
MarkupStringVersionbump once it is tagged.Generated by Claude Code
Summary by CodeRabbit