Make the limit optional in Container.nextSpan(after:limitedBy:). Review and update default implementations

- Make `nextSpan(after:limitedBy:)` the core iteration interface
- Review default algorithms and update them to use it, speeding them up
- Spin off `Span._nextSpan(after:maxCount)` and `Span._nextSpan(after:limitedBy:)` with copying lifetime semantics. This allows forwarding to these without having to override lifetimes.
This commit is contained in:
Karoy Lorentey committed 2026-07-17 16:57:26 -07:00
1 parent 27fe58c42c
commit a7f6b90c99
10 files changed
+193 -131

No files matched your search

@@ -392,6 +392,14 @@ extension UniqueArray where Element: ~Copyable {
_storage.nextSpan(after: &index, maxCount: maxCount)
}
@_alwaysEmitIntoClient
@_lifetime(borrow self)
public func nextSpan(
after index: inout Int, limitedBy limit: Int?
) -> Span<Element> {
_storage.nextSpan(after: &index, limitedBy: limit)
}
@inlinable
@_lifetime(&self)
public mutating func nextMutableSpan(