Skip to content

Commit 4de88de

Browse files
committed
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.
1 parent c759811 commit 4de88de

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Foundation/NSString.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC
297297

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

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

316316
internal var _encodingCantBeStoredInEightBitCFString: Bool {
317317
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
318-
return !_storage._core.isASCII
318+
return !_storage._guts._isContiguousASCII
319319
}
320320
return false
321321
}
@@ -858,7 +858,7 @@ extension NSString {
858858
public func getCString(_ buffer: UnsafeMutablePointer<Int8>, maxLength maxBufferCount: Int, encoding: UInt) -> Bool {
859859
var used = 0
860860
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
861-
if _storage._core.isASCII {
861+
if _storage._guts._isContiguousASCII {
862862
used = min(self.length, maxBufferCount - 1)
863863
_storage._core.startASCII.withMemoryRebound(to: Int8.self,
864864
capacity: used) {

0 commit comments

Comments
 (0)