Repository navigation
Conversation
himura467
force-pushed
the
lazy-substrings-rstring-start
branch
3 times, most recently
from
May 20, 2026 18:37
853f0a7 to
2c8ec8d
Compare
kou
reviewed
May 20, 2026
himura467
force-pushed
the
lazy-substrings-rstring-start
branch
2 times, most recently
from
May 28, 2026 19:17
2f9b7f6 to
bfd6076
Compare
kou
reviewed
May 28, 2026
himura467
force-pushed
the
lazy-substrings-rstring-start
branch
2 times, most recently
from
June 1, 2026 06:38
03a9bc6 to
678ac7f
Compare
himura467
force-pushed
the
lazy-substrings-rstring-start
branch
2 times, most recently
from
June 21, 2026 06:41
56663bf to
b8b60f0
Compare
This reverts commit 5cc7f12.
…the returned pointer is invalidated by any subsequent unsharing operation
…_MIDDLE_SUBSTRING
himura467
force-pushed
the
lazy-substrings-rstring-start
branch
from
June 21, 2026 06:43
b8b60f0 to
5a66cb9
Compare
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.
Summary
This is a PoC for enabling
SHARABLE_MIDDLE_SUBSTRING=1(proposed in https://bugs.ruby-lang.org/issues/19315), which allows zero-copy shared substrings for arbitrary ranges (not just tail ranges).The key challenge is that a shared middle substring may not have a null terminator at
ptr[len], soRSTRING_PTR()must lazily ensure termination before returning the pointer. This PoC implements that guarantee.Thinking
RSTRING_GETMEMinternally callsRSTRING_PTR(), so callers that only need the pointer+length (no null termination) also pay the overhead. ARSTRING_GETMEM_STARTvariant could be added to allow gradual migration of internal callers, while keepingRSTRING_GETMEMfor backward compatibility with C extensions.Testing
Existing tests pass without modification. No new test cases are added in this PoC; proper coverage for middle-shared substrings and multi-byte terminators should be added before merging.