diff --git a/src/swift/Block.swift b/src/swift/Block.swift index 0742190c7..adddc530f 100644 --- a/src/swift/Block.swift +++ b/src/swift/Block.swift @@ -37,14 +37,13 @@ public struct DispatchWorkItemFlags : OptionSet, RawRepresentable { @available(OSX 10.10, iOS 8.0, *) public class DispatchWorkItem { internal var _block: _DispatchBlock - internal var _group: DispatchGroup? public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) { _block = dispatch_block_create_with_qos_class(dispatch_block_flags_t(flags.rawValue), qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block) } - // Used by DispatchQueue.synchronously to provide a @noescape path through + // Used by DispatchQueue.synchronously to provide a path through // dispatch_block_t, as we know the lifetime of the block in question. internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) { _block = _swift_dispatch_block_create_noescape(dispatch_block_flags_t(flags.rawValue), noescapeBlock) diff --git a/src/swift/Data.swift b/src/swift/Data.swift index e81ea99fc..7acf50d65 100644 --- a/src/swift/Data.swift +++ b/src/swift/Data.swift @@ -49,7 +49,6 @@ public struct DispatchData : RandomAccessCollection { /// Initialize a `Data` with copied memory content. /// /// - parameter bytes: A pointer to the memory. It will be copied. - /// - parameter count: The number of bytes to copy. public init(bytes buffer: UnsafeBufferPointer) { let d = dispatch_data_create(buffer.baseAddress!, buffer.count, nil, _dispatch_data_destructor_default()) self.init(data: d) @@ -88,7 +87,7 @@ public struct DispatchData : RandomAccessCollection { public func enumerateBytes( block: (_ buffer: UnsafeBufferPointer, _ byteIndex: Int, _ stop: inout Bool) -> Void) { - _swift_dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in + _swift_dispatch_data_apply(__wrapped.__wrapped) { (_, offset: Int, ptr: UnsafeRawPointer, size: Int) in let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size) let bp = UnsafeBufferPointer(start: bytePtr, count: size) var stop = false @@ -124,7 +123,7 @@ public struct DispatchData : RandomAccessCollection { } } - private func _copyBytesHelper(to pointer: UnsafeMutablePointer, from range: CountableRange) { + private func _copyBytesHelper(to pointer: UnsafeMutableRawPointer, from range: CountableRange) { var copiedCount = 0 _ = CDispatch.dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in let limit = Swift.min((range.endIndex - range.startIndex) - copiedCount, size) @@ -179,10 +178,7 @@ public struct DispatchData : RandomAccessCollection { guard !copyRange.isEmpty else { return 0 } - let bufferCapacity = buffer.count * MemoryLayout.stride - buffer.baseAddress?.withMemoryRebound(to: UInt8.self, capacity: bufferCapacity) { - _copyBytesHelper(to: $0, from: copyRange) - } + _copyBytesHelper(to: buffer.baseAddress!, from: copyRange) return copyRange.count } @@ -244,7 +240,7 @@ public struct DispatchData : RandomAccessCollection { public struct DispatchDataIterator : IteratorProtocol, Sequence { - /// Create an iterator over the given DisaptchData + /// Create an iterator over the given DispatchData public init(_data: DispatchData) { var ptr: UnsafeRawPointer? self._count = 0 diff --git a/src/swift/Wrapper.swift b/src/swift/Wrapper.swift index 367c59abc..ea340e20c 100644 --- a/src/swift/Wrapper.swift +++ b/src/swift/Wrapper.swift @@ -153,7 +153,7 @@ public class DispatchQueue : DispatchObject { _swift_dispatch_release(wrapped()) } - public func sync(execute workItem: @noescape ()->()) { + public func sync(execute workItem: ()->()) { dispatch_sync(self.__wrapped, workItem) } }