mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Avoid StringUTF16View dispatch overhead for some bridged String methods (#83529)
This removes a bunch of overhead on the UTF16 paths in String, as well as consolidating the complicated bits of the logic in one file.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
internal protocol _AbstractStringStorage: _NSCopying {
|
||||
var asString: String { get }
|
||||
var utf16: String.UTF16View { get }
|
||||
var count: Int { get }
|
||||
var isASCII: Bool { get }
|
||||
var start: UnsafePointer<UInt8> { get }
|
||||
@@ -26,6 +27,7 @@ internal protocol _AbstractStringStorage: _NSCopying {
|
||||
|
||||
internal protocol _AbstractStringStorage {
|
||||
var asString: String { get }
|
||||
var utf16: String.UTF16View { get }
|
||||
var count: Int { get }
|
||||
var isASCII: Bool { get }
|
||||
var start: UnsafePointer<UInt8> { get }
|
||||
@@ -295,6 +297,10 @@ final internal class __StringStorage
|
||||
get { String(_StringGuts(self)) }
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
final internal var utf16: String.UTF16View {
|
||||
String.UTF16View(_StringGuts(self))
|
||||
}
|
||||
|
||||
private init(_doNotCallMe: ()) {
|
||||
_internalInvariantFailure("Use the create method")
|
||||
@@ -721,6 +727,11 @@ final internal class __SharedStringStorage
|
||||
return String(_StringGuts(self))
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
final internal var utf16: String.UTF16View {
|
||||
String.UTF16View(_StringGuts(self))
|
||||
}
|
||||
|
||||
internal init(
|
||||
_mortal ptr: UnsafePointer<UInt8>,
|
||||
|
||||
Reference in New Issue
Block a user