Skip to content

Commit b3686f5

Browse files
committed
Remove uses of private API (String._contiguousUTF8)
1 parent a9ed567 commit b3686f5

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

Sources/Basic/ByteString.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ public struct ByteString: ExpressibleByArrayLiteral {
4747

4848
/// Create a byte string from the UTF8 encoding of a string.
4949
public init(encodingAsUTF8 string: String) {
50-
let stringPtrStart = string._contiguousUTF8
51-
defer { _fixLifetime(string) }
52-
if stringPtrStart != nil {
53-
_bytes = [UInt8](UnsafeBufferPointer(start: stringPtrStart, count: string.utf8.count))
54-
} else {
55-
_bytes = [UInt8](string.utf8)
56-
}
50+
_bytes = [UInt8](string.utf8)
5751
}
5852

5953
/// Access the byte string contents as an array.

Sources/Basic/OutputByteStream.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,7 @@ public class OutputByteStream: TextOutputStream {
171171

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

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

0 commit comments

Comments
 (0)