Skip to content

Commit f9f91ef

Browse files
authored
Dispatch: Simplify DispatchData.append(_: UnsafeBufferPointer<T>) (#16080)
The deprecation warning guides us towards UnsafeRawBufferPointer, so sure, let's use that. No intended functionality change.
1 parent 5f9bf11 commit f9f91ef

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

stdlib/public/SDK/Dispatch/Data.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
149149
///
150150
/// - parameter buffer: The buffer of bytes to append. The size is calculated from `SourceType` and `buffer.count`.
151151
public mutating func append<SourceType>(_ buffer : UnsafeBufferPointer<SourceType>) {
152-
buffer.baseAddress!.withMemoryRebound(to: UInt8.self, capacity: buffer.count * MemoryLayout<SourceType>.stride) {
153-
self.append($0, count: buffer.count * MemoryLayout<SourceType>.stride)
154-
}
152+
self.append(UnsafeRawBufferPointer(buffer))
155153
}
156154

157155
private func _copyBytesHelper(to pointer: UnsafeMutableRawPointer, from range: Range<Index>) {

0 commit comments

Comments
 (0)