More exploration of ownership-aware container/iterator algorithms#605
Merged
lorentey merged 10 commits intoapple:mainfrom Mar 17, 2026
Merged
More exploration of ownership-aware container/iterator algorithms#605lorentey merged 10 commits intoapple:mainfrom
lorentey merged 10 commits intoapple:mainfrom
Conversation
…ue to container protocols
…gMapProducer and BorrowingFilter
…thods should consume their input (Because they are running it to completion.)
…to turn borrowing iterators into producers
…eReplaceableContainer This is getting into dangerous territory, as RRC allows fixed-capacity conformers, where appending a producer must be done extremely carefully. We should be using bulk append operations, but never ask the container to reserve any more slots than the producer is able to actually generate. (When the fixed-capacity RRC was carefully sized to precisely fit the generator’s contents, asking it to provide space for even a single item more would lead to a runtime trap.) Additionally, the algorithm should work (and be reasonably efficient) even if the RRC happens to be a dynamically sizing container type. It would be nice if we had a Producer protocol flavor with an exact count; failing that, we can still do this with a bit of acrobatics, as implemented here. (The `DynamicContainer.append(from:)` algorithm was already implemented this way in a previous commit, with an eye towards this case.)
…he new algorithms
0089a80 to
f84e5bc
Compare
…on 6.2 toolchains “Work” in this case means that they can be enabled without breaking the build — not necessarily that all features are available. Swift 6.2 is highly prone to runtime crashes in `swift_getTypeByMangledName` in generic code that uses ownership features. Swift 6.3 will resolve that.
f84e5bc to
8f88cce
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.
.filteronBorrowingIteratorProtocol,Container,ProducerandDrain.RandomAccessContainer,DynamicContainerandMutableContainer.Producerconformances on lazy algorithmsBorrowingIteratorProtocol.copy()algorithm that turns borrowing iterators into producers by copying items.Producer.collect(into:)to allow populating fixed-capacity targetsChecklist