Skip to content

Remove uses of private API (String._contiguousUTF8) #634

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

Merged
merged 1 commit into from
Sep 6, 2016
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions Sources/Basic/ByteString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public struct ByteString: ExpressibleByArrayLiteral {

/// Create a byte string from the UTF8 encoding of a string.
public init(encodingAsUTF8 string: String) {
let stringPtrStart = string._contiguousUTF8
defer { _fixLifetime(string) }
if stringPtrStart != nil {
_bytes = [UInt8](UnsafeBufferPointer(start: stringPtrStart, count: string.utf8.count))
} else {
_bytes = [UInt8](string.utf8)
}
_bytes = [UInt8](string.utf8)
}

/// Access the byte string contents as an array.
Expand Down
9 changes: 1 addition & 8 deletions Sources/Basic/OutputByteStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,7 @@ public class OutputByteStream: TextOutputStream {

/// Write a string to the buffer (as UTF8).
public final func write(_ string: String) {
// Fast path for contiguous strings. For some reason Swift itself
// doesn't implement this optimization: <rdar://problem/24100375> Missing fast path for [UInt8] += String.UTF8View
let stringPtrStart = string._contiguousUTF8
if stringPtrStart != nil {
write(UnsafeBufferPointer(start: stringPtrStart, count: string.utf8.count))
} else {
write(sequence: string.utf8)
}
write(sequence: string.utf8)
}

/// Write a character to the buffer (as UTF8).
Expand Down