Skip to content

Commit a618b46

Browse files
authored
Merge pull request #355 from jrose-apple/appending-doom
Simplify DispatchData.append(_: UnsafeBufferPointer<T>)
2 parents c025baa + 6217b0f commit a618b46

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/swift/Data.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,7 @@ public struct DispatchData : RandomAccessCollection {
168168
///
169169
/// - parameter buffer: The buffer of bytes to append. The size is calculated from `SourceType` and `buffer.count`.
170170
public mutating func append<SourceType>(_ buffer : UnsafeBufferPointer<SourceType>) {
171-
let count = buffer.count * MemoryLayout<SourceType>.stride;
172-
buffer.baseAddress?.withMemoryRebound(to: UInt8.self, capacity: count) {
173-
self.append($0, count: count)
174-
}
171+
self.append(UnsafeRawBufferPointer(buffer))
175172
}
176173

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

0 commit comments

Comments
 (0)