Skip to content

NSString._fastContents: Remove use of deprecated UTF-16 String properties. #2726

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
Mar 14, 2020
Merged
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
12 changes: 5 additions & 7 deletions Sources/Foundation/NSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,14 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC
}
return nil
}

internal var _fastContents: UnsafePointer<UniChar>? {
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
if _storage._guts._isContiguousUTF16 {
return UnsafePointer<UniChar>(_storage._guts.startUTF16)
}
}
// The string held in _storage is a Swift string, natively stored as UTF-8. There is no UTF-16 data that can be
// returned here. If, in the future, CFStrings are lazy-bridged to Swift Strings and the address of the CFString
// is held as a foreign object in the String then it may be possible to return a pointer here.
return nil
}

internal var _encodingCantBeStoredInEightBitCFString: Bool {
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
return !_storage._guts._isContiguousASCII
Expand Down