Drop support for Swift 6.0 and 6.1

This allows the use of Span types without `#if compiler` guards.
This commit is contained in:
Karoy Lorentey committed 2026-09-21 13:34:39 -07:00
1 parent 78bb4bf6b9
commit 537bf9cbfb
145 files changed
+342 -1047

No files matched your search

@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Adds an element to the end of the deque.
@@ -137,7 +135,7 @@ extension RigidDeque where Element: ~Copyable {
precondition(items.count <= freeCapacity, "RigidDeque capacity overflow")
return _handle.uncheckedAppend(moving: items)
}
#if UnstableContainersPreview
/// Moves the elements of an input span by appending them to the end of
/// this deque, leaving the span empty.
@@ -161,7 +159,7 @@ extension RigidDeque where Element: ~Copyable {
}
}
#endif
/// Moves the elements of an output span by appending them to the end of
/// this deque, leaving the span empty.
///
@@ -208,7 +206,7 @@ extension RigidDeque /*where Element: Copyable*/ {
"RigidDeque capacity overflow")
return _handle.uncheckedAppend(copying: items)
}
/// Copies the elements of a buffer and append them to the end of this
/// deque.
///
@@ -227,7 +225,7 @@ extension RigidDeque /*where Element: Copyable*/ {
) -> Range<Int> {
unsafe self.append(copying: UnsafeBufferPointer(items))
}
/// Copies the elements of a span and append them to the end of this deque.
///
/// If the deque does not have sufficient capacity to hold all items in the
@@ -244,7 +242,7 @@ extension RigidDeque /*where Element: Copyable*/ {
unsafe self.append(copying: source)
}
}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@@ -259,7 +257,7 @@ extension RigidDeque /*where Element: Copyable*/ {
self.append(copying: span)
}
}
/// Copies the elements of a borrowing sequence and append them to the end of
/// this deque.
///
@@ -279,7 +277,7 @@ extension RigidDeque /*where Element: Copyable*/ {
try self._append(copying: newElements)
}
#endif
/// Append the elements of a sequence to the end of this deque by copying
/// them.
///
@@ -297,11 +295,11 @@ extension RigidDeque /*where Element: Copyable*/ {
return
}
if done != nil { return }
var it = _handle.uncheckedAppend(copyingPrefixOf: newElements)
precondition(it.next() == nil, "RigidDeque capacity overflow")
}
#if compiler(>=6.4)
/// Copies the elements of a borrowing sequence to the end of this deque.
///
@@ -324,5 +322,3 @@ extension RigidDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
#if UnstableContainersPreview
@@ -46,12 +44,12 @@ extension RigidDeque where Element: ~Copyable {
) -> Index {
_checkValidBounds(subrange)
let segments = self._handle.mutableSegments(forOffsets: subrange)
var span = InputSpan(
buffer: segments.first, initializedCount: segments.first.count)
consumer(&span)
_ = consume span
if let second = segments.second {
var span = InputSpan(buffer: second, initializedCount: second.count)
consumer(&span)
@@ -87,7 +85,7 @@ extension RigidDeque where Element: ~Copyable {
) -> Index {
consumeSubrange(subrange.relative(to: indices), consumingWith: consumer)
}
/// Remove all items currently in this deque, passing a series of input
/// spans to a given callback function to consume them in place.
///
@@ -108,7 +106,7 @@ extension RigidDeque where Element: ~Copyable {
) {
consumeSubrange(indices, consumingWith: consumer)
}
/// Remove the specified number of items from the end of this deque,
/// passing an input span to a given callback function to consume them in
/// place.
@@ -267,5 +265,3 @@ extension RigidDeque.SubrangeConsumer where Element: ~Copyable {
}
}
#endif
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -127,5 +125,3 @@ extension RigidDeque where Element: ~Copyable {
return _overrideLifetime(Span(_unsafeElements: segment), borrowing: self)
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Grow or shrink the capacity of a rigid deque instance without discarding
@@ -303,5 +301,3 @@ extension RigidDeque /* where Element: Copyable */ {
replaceSubrange(subrange, copying: items)
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque /*: CustomStringConvertible */ where Element: ~Copyable {
public var description: String {
@@ -28,5 +26,3 @@ extension RigidDeque /*: CustomDebugStringConvertible */ where Element: ~Copyabl
"<\(count) items>"
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
@@ -65,5 +63,3 @@ extension RigidDeque where Element: Equatable {
}
}
#endif
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
@@ -48,5 +46,3 @@ extension RigidDeque where Element: Hashable {
}
}
#endif
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Initializes a new rigid deque with zero capacity and no elements.
@@ -32,7 +30,7 @@ extension RigidDeque where Element: ~Copyable {
public init(capacity: Int) {
self.init(_handle: .allocate(capacity: capacity))
}
/// Creates a rigid deque with the specified capacity, then calls the given
/// closure with an output span covering the deque's uninitialized memory.
///
@@ -141,7 +139,7 @@ extension RigidDeque /*where Element: Copyable*/ {
self.init(capacity: capacity ?? contents.count)
self.append(copying: contents)
}
#if compiler(>=6.4)
/// Creates a new deque with the specified capacity, holding a copy
/// of the contents of a given sequence.
@@ -186,5 +184,3 @@ extension RigidDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Inserts a new element into the deque at the specified position.
@@ -368,5 +366,3 @@ extension RigidDeque /* where Element: Copyable */ {
at: index, copying: items, newCount: items.count)
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Adds an element to the front of the deque.
@@ -34,7 +32,7 @@ extension RigidDeque where Element: ~Copyable {
precondition(!isFull, "RigidDeque capacity overflow")
_handle.uncheckedPrepend(item)
}
/// Adds an element to the front of the deque, if possible.
///
/// If the deque does not have sufficient capacity to hold any more elements,
@@ -140,7 +138,7 @@ extension RigidDeque where Element: ~Copyable {
precondition(items.count <= freeCapacity, "RigidDeque capacity overflow")
return _handle.uncheckedPrepend(moving: items)
}
#if UnstableContainersPreview
/// Moves the elements of an input span by prepending them to the front of
/// this deque, leaving the span empty.
@@ -164,7 +162,7 @@ extension RigidDeque where Element: ~Copyable {
}
}
#endif
/// Moves the elements of an output span by prepending them to the front of
/// this deque, leaving the span empty.
///
@@ -212,7 +210,7 @@ extension RigidDeque /*where Element: Copyable*/ {
"RigidDeque capacity overflow")
return _handle.uncheckedPrepend(copying: items)
}
/// Copies the elements of a buffer and prepend them to the front of this
/// deque.
///
@@ -232,7 +230,7 @@ extension RigidDeque /*where Element: Copyable*/ {
) -> Range<Int> {
unsafe self.prepend(copying: UnsafeBufferPointer(items))
}
/// Copy the elements of a span and prepend them to the front of this deque.
///
/// If the deque does not have sufficient capacity to hold all items in the
@@ -250,7 +248,7 @@ extension RigidDeque /*where Element: Copyable*/ {
unsafe self.prepend(copying: source)
}
}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@inlinable
@@ -287,7 +285,7 @@ extension RigidDeque /*where Element: Copyable*/ {
target._append(copying: span)
}
}
/// Copies the elements of a borrowing sequence and prepend them to the front
/// of this deque.
///
@@ -380,7 +378,7 @@ extension RigidDeque /*where Element: Copyable*/ {
precondition(c <= freeCapacity, "RigidDeque capacity overflow")
return _handle.uncheckedPrepend(copying: items, exactCount: c)
}
#if compiler(>=6.4)
/// Copies the elements of a borrowing sequence to the front of this deque.
///
@@ -420,4 +418,3 @@ extension RigidDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Removes and returns the element at the specified position.
@@ -64,7 +62,7 @@ extension RigidDeque where Element: ~Copyable {
public mutating func removeAll() {
_handle.uncheckedRemoveAll()
}
/// Removes and returns the first element of the deque.
///
/// The deque must not be empty.
@@ -98,7 +96,7 @@ extension RigidDeque where Element: ~Copyable {
precondition(!isEmpty, "Cannot remove last element of an empty RigidDeque")
return _handle.uncheckedRemoveLast()
}
/// Removes and discards the specified number of elements from the start of
/// the deque.
///
@@ -142,7 +140,7 @@ extension RigidDeque where Element: ~Copyable {
precondition(n <= count, "Cannot remove more elements than there are in the container")
_handle.uncheckedRemoveLast(n)
}
/// Removes the specified subrange of elements from the deque.
///
/// - Parameter bounds: The subrange to remove. The bounds of the
@@ -188,5 +186,3 @@ extension RigidDeque where Element: ~Copyable {
return _handle.uncheckedRemoveLast()
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// Replaces the specified range of elements by a given count of new items,
@@ -77,7 +75,7 @@ extension RigidDeque where Element: ~Copyable {
addingCount: newItemCount,
initializingWith: initializer)
}
#if UnstableContainersPreview
/// Replaces the specified range of elements by a given count of new items,
/// using callbacks to consume old items, and to then insert new ones.
@@ -204,7 +202,7 @@ extension RigidDeque where Element: ~Copyable {
assert(remainder.isEmpty)
return range
}
#if UnstableContainersPreview
/// Replaces the specified range of elements by moving the contents of an
/// input span into their place. On return, the span is left empty.
@@ -466,5 +464,3 @@ extension RigidDeque /* where Element: Copyable */ {
_replaceSubrange(subrange, copyingCollection: items, newCount: items.count)
}
}
#endif
@@ -18,8 +18,6 @@ import InternalCollectionsUtilities
// This file contains exported but non-public entry points to support clear box
// testing.
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
/// The number of the storage slot in this deque that holds the first element.
@@ -48,7 +46,7 @@ extension RigidDeque {
copying contents: some Sequence<Element>
) {
let contents = Array(contents)
self.init(capacity: capacity)
_handle.startSlot = _handle.slot(_handle.startSlot, offsetBy: startSlot)
self.append(copying: contents)
@@ -57,5 +55,3 @@ extension RigidDeque {
assert(self.count == contents.count)
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Adds an element to the end of the deque.
@@ -121,7 +119,7 @@ extension UniqueDeque where Element: ~Copyable {
_ensureFreeCapacity(items.count)
return _storage._handle.uncheckedAppend(moving: items)
}
#if UnstableContainersPreview
/// Moves the elements of an input span by appending them to the end of
/// this deque, leaving the span empty.
@@ -147,7 +145,7 @@ extension UniqueDeque where Element: ~Copyable {
}
}
#endif
/// Moves the elements of an output span by appending them to the end of
/// this deque, leaving the span empty.
///
@@ -302,7 +300,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
_storage.append(item)
}
}
#if compiler(>=6.4)
/// Copies the elements of a borrowing sequence to the end of this deque.
///
@@ -325,5 +323,3 @@ extension UniqueDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
#if UnstableContainersPreview
@@ -70,7 +68,7 @@ extension UniqueDeque where Element: ~Copyable {
) {
consumeSubrange(subrange.relative(to: indices), consumingWith: consumer)
}
/// Remove all items currently in this deque, passing a series of input
/// spans to a given callback function to consume them in place.
///
@@ -91,7 +89,7 @@ extension UniqueDeque where Element: ~Copyable {
) {
consumeSubrange(indices, consumingWith: consumer)
}
/// Remove the specified number of items from the end of this deque,
/// passing an input span to a given callback function to consume them in
/// place.
@@ -162,5 +160,3 @@ extension UniqueDeque where Element: ~Copyable {
}
}
#endif
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -97,5 +95,3 @@ extension UniqueDeque where Element: ~Copyable {
_storage.previousSpan(before: &index, maxCount: maxCount)
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Creates an empty unique deque with the specified capacity.
@@ -328,5 +326,3 @@ extension UniqueDeque /* where Element: Copyable */ {
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque /*: CustomStringConvertible */ where Element: ~Copyable {
public var description: String {
@@ -28,5 +26,3 @@ extension UniqueDeque /*: CustomDebugStringConvertible */ where Element: ~Copyab
"<\(count) items>"
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
@@ -51,5 +49,3 @@ extension UniqueDeque where Element: Equatable {
}
}
#endif
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
extension UniqueDeque: Hashable where Element: Hashable & ~Copyable {
@@ -34,5 +32,3 @@ extension UniqueDeque where Element: Hashable {
}
}
#endif
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Initializes a new unique deque with no elements.
@@ -122,7 +120,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
self.init(minimumCapacity: capacity ?? contents.underestimatedCount)
self.append(copying: contents)
}
#if compiler(>=6.4)
/// Creates a new deque with the specified capacity, holding a copy
/// of the contents of a given sequence.
@@ -164,5 +162,3 @@ extension UniqueDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Inserts a new element into the deque at the specified position.
@@ -386,5 +384,3 @@ extension UniqueDeque /* where Element: Copyable */ {
at: index, copying: items, newCount: items.count)
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Adds an element to the front of the deque.
@@ -126,7 +124,7 @@ extension UniqueDeque where Element: ~Copyable {
_ensureFreeCapacity(items.count)
return _storage._handle.uncheckedPrepend(moving: items)
}
#if UnstableContainersPreview
/// Moves the elements of an input span by prepending them to the front of
/// this deque, leaving the span empty.
@@ -152,7 +150,7 @@ extension UniqueDeque where Element: ~Copyable {
}
}
#endif
/// Moves the elements of an output span by prepending them to the front of
/// this deque, leaving the span empty.
///
@@ -201,7 +199,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
_ensureFreeCapacity(items.count)
return _storage._handle.uncheckedPrepend(copying: items)
}
/// Copies the elements of a buffer and prepend them to the front of this
/// deque.
///
@@ -221,7 +219,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
) -> Range<Int> {
unsafe self.prepend(copying: UnsafeBufferPointer(items))
}
/// Copy the elements of a span and prepend them to the front of this deque.
///
/// If the deque does not have sufficient capacity to hold all items in the
@@ -239,7 +237,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
unsafe self.prepend(copying: source)
}
}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@inlinable
@@ -273,7 +271,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
target._append(copying: span)
}
}
/// Copies the elements of a borrowing sequence and prepend them to the front
/// of this deque.
///
@@ -370,7 +368,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
_ensureFreeCapacity(c)
return _storage._handle.uncheckedPrepend(copying: items, exactCount: c)
}
#if compiler(>=6.4)
/// Copies the elements of a borrowing sequence to the end of this deque.
///
@@ -412,4 +410,3 @@ extension UniqueDeque /*where Element: Copyable*/ {
}
#endif
}
#endif
@@ -15,8 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Removes and returns the element at the specified position.
@@ -36,7 +34,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func remove(at index: Int) -> Element {
_storage.remove(at: index)
}
/// Removes all elements from the deque, preserving its allocated capacity.
///
/// - Complexity: O(`count`)
@@ -45,7 +43,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func removeAll() {
_storage.removeAll()
}
/// Removes and returns the first element of the deque.
///
/// The deque must not be empty.
@@ -59,7 +57,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func removeFirst() -> Element {
_storage.removeFirst()
}
/// Removes and returns the last element of the deque.
///
/// The deque must not be empty.
@@ -73,7 +71,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func removeLast() -> Element {
_storage.removeLast()
}
/// Removes and discards the specified number of elements from the start of
/// the deque.
///
@@ -90,7 +88,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func removeFirst(_ k: Int) {
_storage.removeFirst(k)
}
/// Removes and discards the specified number of elements from the end of the
/// deque.
///
@@ -107,7 +105,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func removeLast(_ k: Int) {
_storage.removeLast(k)
}
/// Removes the specified subrange of elements from the deque.
///
/// - Parameter bounds: The subrange to remove. The bounds of the
@@ -149,5 +147,3 @@ extension UniqueDeque where Element: ~Copyable {
_storage.popLast()
}
}
#endif
@@ -16,8 +16,6 @@ import InternalCollectionsUtilities
import SpanPreview
#endif
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
/// Replaces the specified range of elements by a given count of new items,
@@ -89,7 +87,7 @@ extension UniqueDeque where Element: ~Copyable {
addingCount: newItemCount,
initializingWith: initializer)
}
#if UnstableContainersPreview
/// Replaces the specified range of elements by a given count of new items,
/// using callbacks to consume old items, and to then insert new ones.
@@ -212,7 +210,7 @@ extension UniqueDeque where Element: ~Copyable {
assert(remainder.isEmpty)
return range
}
#if UnstableContainersPreview
/// Replaces the specified range of elements by moving the contents of an
/// input span into their place. On return, the span is left empty.
@@ -480,5 +478,3 @@ extension UniqueDeque /* where Element: Copyable */ {
_replaceSubrange(subrange, copyingCollection: items, newCount: items.count)
}
}
#endif
+20 -28
View File
@@ -215,13 +215,13 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
guard position < capacity else { return Slot(at: position &- capacity) }
return Slot(at: position)
}
@_alwaysEmitIntoClient
@_transparent
internal func distance(from start: Slot, to end: Slot) -> Int {
assert(start.position >= 0 && start.position <= capacity)
assert(end.position >= 0 && end.position <= capacity)
if end.position >= start.position {
return end.position - start.position
} else {
@@ -633,7 +633,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
self.count = 0
}
@_alwaysEmitIntoClient
@_transparent
internal mutating func unsafeConsumePrefix(
@@ -666,7 +666,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
mutablePtr(at: endSlot).initialize(to: element)
count &+= 1
}
/// Prepend `element` to the front of this buffer. The buffer must have enough
/// free capacity to insert one new element.
///
@@ -683,7 +683,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
}
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension UnsafeMutableBufferPointer where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -700,7 +699,6 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
return try body(&span)
}
}
#endif
extension _UnsafeDequeHandle where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -727,7 +725,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
}
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension _UnsafeDequeHandle where Element: ~Copyable {
/// Append a given number of items to the end of this deque by populating
@@ -769,7 +766,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
return Range(uncheckedBounds: (origCount, count))
}
/// Prepend a given number of items to the end of this deque by populating
/// a series of storage regions through repeated calls of the specified
/// callback function.
@@ -835,7 +832,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
return Range(uncheckedBounds: (0, c))
}
}
#endif
@available(SwiftStdlib 5.0, *)
extension _UnsafeDequeHandle where Element: ~Copyable {
@@ -858,7 +854,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
gap.first.moveInitializeAll(
fromContentsOf: items._extracting(first: gap.first.count))
if let second = gap.second {
assert(gap.first.count + second.count == items.count)
second.moveInitializeAll(
@@ -866,7 +862,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
return Range(uncheckedBounds: (count &- items.count, count))
}
/// Prepends the elements of a buffer to the front of this deque, leaving the
/// buffer uninitialized.
///
@@ -886,7 +882,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
gap.first.moveInitializeAll(
fromContentsOf: items._extracting(first: gap.first.count))
if let second = gap.second {
assert(gap.first.count + second.count == items.count)
second.moveInitializeAll(
@@ -911,7 +907,7 @@ extension _UnsafeDequeHandle {
gap.initialize(copying: source)
return Range(uncheckedBounds: (count &- source.count, count))
}
/// Prepend the contents of `source` to this buffer. The buffer must have
/// enough free capacity to insert the new elements.
///
@@ -941,7 +937,7 @@ extension _UnsafeDequeHandle {
self.count += c
return it
}
@_alwaysEmitIntoClient
@inline(__always)
internal mutating func uncheckedPrepend<C: Collection<Element>>(
@@ -1259,7 +1255,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
if gapSize > 0 {
_ = openGap(ofSize: gapSize, atOffset: newStart)
}
// With the prefix and suffix swapped, update the starting slot and
// restore the count.
startSlot = slot(startSlot, offsetBy: newStart - oldCount)
@@ -1291,7 +1287,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
}
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension _UnsafeDequeHandle where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -1302,7 +1297,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
) throws(E) -> Range<Int> {
guard newItemCount > 0 else { return offset ..< offset }
let gap = self.openGap(ofSize: newItemCount, atOffset: offset)
var c = 0
defer {
if c < newItemCount {
@@ -1316,7 +1311,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
return Range(uncheckedBounds: (offset, offset &+ c))
}
}
#endif
extension _UnsafeDequeHandle {
/// Insert all elements from `newElements` into this deque, starting at
@@ -1355,7 +1349,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
closeGap(offsets: Range(uncheckedBounds: (offset, offset + 1)))
return result
}
@_alwaysEmitIntoClient
@_transparent
internal mutating func uncheckedRemoveFirst() -> Element {
@@ -1365,7 +1359,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
count -= 1
return result
}
@_alwaysEmitIntoClient
@_transparent
internal mutating func uncheckedRemoveLast() -> Element {
@@ -1375,7 +1369,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
count -= 1
return result
}
@_alwaysEmitIntoClient
@_transparent
internal mutating func uncheckedRemoveFirst(_ n: Int) {
@@ -1386,7 +1380,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
startSlot = slot(startSlot, offsetBy: n)
count -= n
}
@_alwaysEmitIntoClient
@_transparent
internal mutating func uncheckedRemoveLast(_ n: Int) {
@@ -1396,7 +1390,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
target.deinitialize()
count -= n
}
/// Remove all elements stored in this instance, deinitializing their storage.
///
/// This method does not ensure that the storage buffer is uniquely
@@ -1410,7 +1404,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
count = 0
startSlot = .zero
}
/// Remove all elements in `bounds`, deinitializing their storage and sliding
/// remaining elements to close the resulting gap.
///
@@ -1420,7 +1414,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
@_transparent
internal mutating func uncheckedRemove(offsets bounds: Range<Int>) -> Int {
assert(bounds.lowerBound >= 0 && bounds.upperBound <= self.count)
// Deinitialize elements in `bounds`.
mutableSegments(forOffsets: bounds).deinitialize()
closeGap(offsets: bounds)
@@ -1430,7 +1424,6 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
// MARK: Replacement
#if compiler(>=6.2)
@available(SwiftStdlib 5.0, *)
extension _UnsafeDequeHandle where Element: ~Copyable {
@_alwaysEmitIntoClient
@@ -1456,7 +1449,7 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
subrange.lowerBound,
subrange.lowerBound &+ newItemCount))
let gap = self.mutableSegments(forOffsets: newRange)
var c = 0
defer {
if c < newItemCount {
@@ -1519,4 +1512,3 @@ extension _UnsafeDequeHandle where Element: ~Copyable {
}
#endif
}
#endif