diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Append.swift b/Sources/BasicContainers/RigidArray/RigidArray+Append.swift index 23b43076..8a0744d8 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Append.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Append.swift @@ -153,19 +153,6 @@ extension RigidArray where Element: ~Copyable { } #endif - @_alwaysEmitIntoClient - @unsafe - internal mutating func _appendUnchecked( - moving items: inout OutputSpan - ) { - // FIXME: Remove this when `OutputSpan` starts conforming to RangeReplaceableContainer - items.withUnsafeMutableBufferPointer { buffer, count in - let source = buffer._extracting(first: count) - unsafe _appendUnchecked(moving: source) - count = 0 - } - } - /// Moves the elements of an output span to the end of this array, leaving the /// span empty. /// @@ -180,8 +167,13 @@ extension RigidArray where Element: ~Copyable { public mutating func append( moving items: inout OutputSpan ) { + // FIXME: Remove this when `OutputSpan` starts conforming to RangeReplaceableContainer precondition(items.count <= freeCapacity, "RigidArray capacity overflow") - _appendUnchecked(moving: &items) + items.withUnsafeMutableBufferPointer { buffer, count in + let source = buffer._extracting(first: count) + unsafe _appendUnchecked(moving: source) + count = 0 + } } #if !UnstableContainersPreview @@ -257,14 +249,6 @@ extension RigidArray { unsafe self.append(copying: UnsafeBufferPointer(items)) } - @_alwaysEmitIntoClient - @unsafe - internal mutating func _appendUnchecked(copying items: Span) { - items.withUnsafeBufferPointer { source in - unsafe _appendUnchecked(copying: source) - } - } - /// Copies the elements of a span to the end of this array. /// /// If the array does not have sufficient capacity to hold all items in the @@ -277,7 +261,9 @@ extension RigidArray { @_alwaysEmitIntoClient public mutating func append(copying items: Span) { precondition(items.count <= freeCapacity, "RigidArray capacity overflow") - _appendUnchecked(copying: items) + items.withUnsafeBufferPointer { source in + unsafe _appendUnchecked(copying: source) + } } @_alwaysEmitIntoClient diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift index 7afc0961..9962a377 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift @@ -129,7 +129,11 @@ extension UniqueArray where Element: ~Copyable { moving items: inout OutputSpan ) { _ensureFreeCapacity(items.count) - unsafe _storage._appendUnchecked(moving: &items) + items.withUnsafeMutableBufferPointer { buffer, count in + let source = buffer._extracting(first: count) + unsafe _appendUnchecked(moving: source) + count = 0 + } } #if !UnstableContainersPreview @@ -254,7 +258,9 @@ extension UniqueArray { @_alwaysEmitIntoClient public mutating func append(copying newElements: Span) { _ensureFreeCapacity(newElements.count) - unsafe _storage._appendUnchecked(copying: newElements) + items.withUnsafeBufferPointer { source in + unsafe _storage._appendUnchecked(copying: source) + } } #if compiler(>=6.4) && UnstableContainersPreview