-
Notifications
You must be signed in to change notification settings - Fork 404
InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Catfish-Man
wants to merge
38
commits into
apple:main
Choose a base branch
from
Catfish-Man:leeloo-dallas-multispan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c2944fb
WIP OutputMultispan + basic adoption in RigidArray and UniqueArray
Catfish-Man 146c2cd
Update Sources/ContainersPreview/Types/OutputMultispan.swift
Catfish-Man a9fc724
WIP InputMultispan
Catfish-Man b7fe7ec
Fix a bunch of bugs in OutputMultispan
Catfish-Man fc4adec
Add InputMultispan to the project file
Catfish-Man 03a4083
Build fixes
Catfish-Man 97322b2
Many more fixes
Catfish-Man b8992db
Review cleanup
Catfish-Man e183879
Add new files to cmake
Catfish-Man 81b2d37
Yet more fixes
Catfish-Man e97fd9a
Merge branch 'main' into leeloo-dallas-multispan
Catfish-Man 5ec9c1a
Fix problems exposed by a newer swiftc
Catfish-Man a0512f4
Preliminary tests for OutputMultispan. Note: several of them fail cur…
Catfish-Man 8a0506f
OutputMultispan tests pass now!
Catfish-Man df666c5
InputMultispan test fixes
Catfish-Man 31c8c74
Add tests to project, oops
Catfish-Man 5ad3a47
Add inline storage support, but don't adopt it yet
Catfish-Man c422c75
Adopt inline storage and deduplicate some logic
Catfish-Man d1dbe97
Minor cleanup and inlining
Catfish-Man f61fabb
Address optimization TODOs
Catfish-Man db9f5f9
Review fixes
Catfish-Man e6a68b2
More review fixes
Catfish-Man 6350725
Remove stray logging in the tests
Catfish-Man 0b76d6f
Merge remote-tracking branch 'github/main' into leeloo-dallas-multispan
Catfish-Man a48b43a
Update license headers for new files
Catfish-Man 0d2d90f
Missed one
Catfish-Man 0e7016f
Adjust things to make the package buildable
lorentey 31aeffe
Switch from type punning to an enum
Catfish-Man 6f73381
Fix compile errors and switch to @lifetime()
Catfish-Man 64a5117
Switch back to _lifetime, I had misunderstood
Catfish-Man 3599608
Merge branch 'main' into leeloo-dallas-multispan
Catfish-Man 7e21887
Fix build failures
Catfish-Man 478d3ec
Fix test build failures
Catfish-Man 6e45911
Merge remote-tracking branch 'github/main' into leeloo-dallas-multispan
Catfish-Man dd2b476
Resolve ambiguous methods
Catfish-Man 0006013
Merge remote-tracking branch 'origin/main' into leeloo-dallas-multispan
lorentey 2e1f550
Oops, fix RawCollider conflict
lorentey b387eba
{Input,Output}Multispan: Fix bug in index validation
lorentey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
71 changes: 71 additions & 0 deletions
71
Sources/ContainersPreview/Extensions/OutputMultispan+Extras.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2024 - 2026 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #if compiler(>=6.2) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW | ||
|
|
||
| #if !COLLECTIONS_SINGLE_MODULE | ||
| import InternalCollectionsUtilities | ||
| #endif | ||
|
|
||
| @available(SwiftStdlib 5.0, *) | ||
| extension RigidArray where Element: ~Copyable { | ||
| @_alwaysEmitIntoClient | ||
| public mutating func append<E: Error>( | ||
| addingCount newItemCount: Int, | ||
| initializingWith initializer: @escaping (inout OutputMultispan<Element>) async throws(E) -> Void | ||
| ) async throws(E) { | ||
| precondition(newItemCount >= 0, "Cannot add a negative number of items") | ||
| precondition(freeCapacity >= newItemCount, "RigidArray capacity overflow") | ||
| let buffer = _freeSpace._extracting(first: newItemCount) | ||
| var span = OutputSpan(buffer: buffer, initializedCount: 0) | ||
| defer { | ||
| _count &+= span.finalize(for: buffer) | ||
| span = OutputSpan() | ||
| } | ||
| var multiSpan = OutputMultispan<Element>() | ||
| multiSpan._appendSpan(&span) | ||
| return try await initializer(&multiSpan) | ||
| } | ||
|
|
||
| @inlinable | ||
| public init<E: Error>( | ||
| capacity: Int, | ||
| initializingWith body: @escaping (inout OutputMultispan<Element>) throws(E) -> Void | ||
| ) async throws(E) { | ||
| self.init(capacity: capacity) | ||
| try await append(addingCount: capacity, initializingWith: body) | ||
| } | ||
| } | ||
|
|
||
| @available(SwiftStdlib 5.0, *) | ||
| extension UniqueArray where Element: ~Copyable { | ||
| @_alwaysEmitIntoClient | ||
| public mutating func append<E: Error>( | ||
| addingCount newItemCount: Int, | ||
| initializingWith initializer: @escaping (inout OutputMultispan<Element>) async throws(E) -> Void | ||
| ) async throws(E) { | ||
| _ensureFreeCapacity(newItemCount) | ||
| return try await _storage.append( | ||
| addingCount: newItemCount, | ||
| initializingWith: initializer) | ||
| } | ||
|
|
||
| @inlinable | ||
| public init<E: Error>( | ||
| capacity: Int, | ||
| initializingWith body: @escaping (inout OutputMultispan<Element>) throws(E) -> Void | ||
| ) async throws(E) { | ||
| self.init(capacity: capacity) | ||
| try await append(addingCount: capacity, initializingWith: body) | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.