Skip to content

Update Data.swift documentation #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/swift/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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: UnsafeRawBufferPointer) {
let d = buffer.baseAddress == nil ? _swift_dispatch_data_empty()
: dispatch_data_create(buffer.baseAddress!, buffer.count, nil,
Expand All @@ -84,7 +83,6 @@ public struct DispatchData : RandomAccessCollection {
/// Initialize a `Data` without copying the bytes.
///
/// - parameter bytes: A pointer to the bytes.
/// - parameter count: The size of the bytes.
/// - parameter deallocator: Specifies the mechanism to free the indicated buffer.
public init(bytesNoCopy bytes: UnsafeRawBufferPointer, deallocator: Deallocator = .free) {
let (q, b) = deallocator._deallocator
Expand Down Expand Up @@ -162,7 +160,6 @@ public struct DispatchData : RandomAccessCollection {
/// Append bytes to the data.
///
/// - parameter bytes: A pointer to the bytes to copy in to the data.
/// - parameter count: The number of bytes to copy.
public mutating func append(_ bytes: UnsafeRawBufferPointer) {
// Nil base address does nothing.
guard bytes.baseAddress != nil else { return }
Expand All @@ -172,7 +169,7 @@ public struct DispatchData : RandomAccessCollection {

/// Append data to the data.
///
/// - parameter data: The data to append to this data.
/// - parameter other: The data to append to this data.
public mutating func append(_ other: DispatchData) {
let data = CDispatch.dispatch_data_create_concat(__wrapped.__wrapped, other.__wrapped.__wrapped)
__wrapped = __DispatchData(data: data, owned: true)
Expand All @@ -181,7 +178,7 @@ public struct DispatchData : RandomAccessCollection {
/// Append a buffer of bytes to the data.
///
/// - parameter buffer: The buffer of bytes to append. The size is calculated from `SourceType` and `buffer.count`.
public mutating func append<SourceType>(_ buffer : UnsafeBufferPointer<SourceType>) {
public mutating func append<SourceType>(_ buffer: UnsafeBufferPointer<SourceType>) {
self.append(UnsafeRawBufferPointer(buffer))
}

Expand Down