CharacterSet: Memory-related Enhancements #2027
Merged
chloe-yeo merged 3 commits intoJun 9, 2026
Merged
Conversation
…es of Data allocation
… Data but we get a buffer than we fill in
cleanup 2 clean up 3 clean up 3 cleanup 4 cleanup 4 cleanup add comments + cleanup cleanup SetAlgebra file add comment about safety of immortal pointer refactor to avoid logic duplication add fatalError add check for cachedBMP explicitly copy Data for built-in sets Data that was initialized by bytesNoCopy streamline bitmapAll & bitmapEmpty cases handling + callsites cleanup remove conditional checking refactor bitmapBacked init deduplication address comments cleanup add test for copy add unit test for union and intersection add tests + address warnings address comment fix cleanup add comment + test add release only call makeBitmap() inside .bitmapFilled cases avoid busy work + add union test for additional validation preserve existing behavior recover previous method
CharacterSet: Memory-related Enhacements CharacterSet: Memory-related Enhancements
Contributor
Author
|
@swift-ci please test |
jrflat
approved these changes
Jun 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.
This PR introduces a method that fills a buffer for a specified plane of a
BuiltInUnicodeScalarSetso that mutating methods inCharacterSetdo not instantiate 8KB ofDatathat are immediately thrown away after thatDatahas been used for mutating another buffer via mutating methods such as union and intersection. The method is equivalent in functionality to the previousbitmap(forPlane:isInverted:)method.Motivation:
This is a change that helps to reduce the memory usage of
CharacterSetwhen trying to fillAnnexplanes of built-inCharacterSets.Modifications:
Added a method
bitmap(forPlane:isInverted:into:apply:)method and refactoredbitmap(forPlane:isInverted:)to call into it to avoid duplicate logic.Result:
There should be no behavioral change.
Testing:
All the existing unit tests should still pass.