@@ -91,11 +91,13 @@ public struct DispatchData : RandomAccessCollection {
91
91
public func enumerateBytes(
92
92
block: ( _ buffer: UnsafeBufferPointer < UInt8 > , _ byteIndex: Int , _ stop: inout Bool ) -> Void )
93
93
{
94
- _swift_dispatch_data_apply ( __wrapped. __wrapped) { ( _, offset: Int , ptr: UnsafeRawPointer , size: Int ) in
94
+ // FIXME: When SR-2313 (withoutActuallyEscaping) is implemented, use it to replace unsafeBitCast
95
+ let nonEscapingBlock = unsafeBitCast ( block, to: _enumerateBytesBlock. self)
96
+ _ = CDispatch . dispatch_data_apply ( __wrapped. __wrapped) { ( _, offset: Int , ptr: UnsafeRawPointer , size: Int ) in
95
97
let bytePtr = ptr. bindMemory ( to: UInt8 . self, capacity: size)
96
98
let bp = UnsafeBufferPointer ( start: bytePtr, count: size)
97
99
var stop = false
98
- block ( bp, offset, & stop)
100
+ nonEscapingBlock ( bp, offset, & stop)
99
101
return !stop
100
102
}
101
103
}
@@ -271,10 +273,7 @@ public struct DispatchDataIterator : IteratorProtocol, Sequence {
271
273
internal var _position : DispatchData . Index
272
274
}
273
275
274
- typealias _swift_data_applier = @convention ( block) ( dispatch_data_t , Int , UnsafeRawPointer , Int ) -> Bool
275
-
276
- @_silgen_name ( " _swift_dispatch_data_apply " )
277
- internal func _swift_dispatch_data_apply( _ data: dispatch_data_t , _ block: _swift_data_applier )
276
+ typealias _enumerateBytesBlock = ( _ buffer: UnsafeBufferPointer < UInt8 > , _ byteIndex: Int , _ stop: inout Bool ) -> Void
278
277
279
278
@_silgen_name ( " _swift_dispatch_data_empty " )
280
279
internal func _swift_dispatch_data_empty( ) -> dispatch_data_t
0 commit comments