From 4de88de0a1b0d3489b0edcc0f7e4698b370eb6dc Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Sat, 24 Mar 2018 15:21:59 -0700 Subject: [PATCH] Switch to less misleading String SPI. Switch off of old _StringCore (which no longer exists)'s isASCII SPI to a check whether the String explicitly stores contiguous ASCII, as opposed to small or non-contiguous contents. --- Foundation/NSString.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Foundation/NSString.swift b/Foundation/NSString.swift index d54e5af369..68c2117927 100644 --- a/Foundation/NSString.swift +++ b/Foundation/NSString.swift @@ -297,7 +297,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC internal func _fastCStringContents(_ nullTerminated: Bool) -> UnsafePointer? { 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.self) } } @@ -306,7 +306,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC internal var _fastContents: UnsafePointer? { if type(of: self) == NSString.self || type(of: self) == NSMutableString.self { - if !_storage._core.isASCII { + if _storage._guts._isContiguousUTF16 { return UnsafePointer(_storage._core.startUTF16) } } @@ -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 } @@ -858,7 +858,7 @@ extension NSString { public func getCString(_ buffer: UnsafeMutablePointer, 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) {