Skip to content

Commit 62d1024

Browse files
committed
1 parent 960e638 commit 62d1024

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Sources/Task.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,10 @@ private final class Pipe {
180180
channel.setLimit(lowWater: 1)
181181
channel.read(offset: 0, length: Int.max, queue: self.queue) { (done, dispatchData, error) in
182182
if let dispatchData = dispatchData {
183-
let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: dispatchData.count)
184-
dispatchData.copyBytes(to: bytes, count: dispatchData.count)
185-
let data = Data(bytes: bytes, count: dispatchData.count)
186-
bytes.deinitialize(count: dispatchData.count)
187-
bytes.deallocate(capacity: dispatchData.count)
188-
183+
// Cast DispatchData to Data.
184+
// See https://gist.github.com/mayoff/6e35e263b9ddd04d9b77e5261212be19.
185+
let data = dispatchData as Any as! NSData as Data
186+
189187
observer.send(value: data)
190188
}
191189

0 commit comments

Comments
 (0)