Skip to content

[string] Wean off of no-longer-supported String non-API #1484

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 26, 2018
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
8 changes: 4 additions & 4 deletions Foundation/NSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC

internal func _fastCStringContents(_ nullTerminated: Bool) -> UnsafePointer<Int8>? {
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
if _storage._core.isASCII {
if _storage._guts._isContiguousASCII {
return unsafeBitCast(_storage._core.startASCII, to: UnsafePointer<Int8>.self)
}
}
Expand All @@ -306,7 +306,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC

internal var _fastContents: UnsafePointer<UniChar>? {
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
if !_storage._core.isASCII {
if _storage._guts._isContiguousUTF16 {
return UnsafePointer<UniChar>(_storage._core.startUTF16)
}
}
Expand All @@ -315,7 +315,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC

internal var _encodingCantBeStoredInEightBitCFString: Bool {
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
return !_storage._core.isASCII
return !_storage._guts._isContiguousASCII
}
return false
}
Expand Down Expand Up @@ -858,7 +858,7 @@ extension NSString {
public func getCString(_ buffer: UnsafeMutablePointer<Int8>, maxLength maxBufferCount: Int, encoding: UInt) -> Bool {
var used = 0
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
if _storage._core.isASCII {
if _storage._guts._isContiguousASCII {
used = min(self.length, maxBufferCount - 1)
_storage._core.startASCII.withMemoryRebound(to: Int8.self,
capacity: used) {
Expand Down