Skip to content

Commit 2d79a5a

Browse files
committed
[string] Wean off of no-longer-supported String non-API
String's _core disappeared, but we kept around a mock-up of it as a faux-SPI to avoid breaking Foundation. However, it does not fully model String, and the illusion is broken from small string support.
1 parent c759811 commit 2d79a5a

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

Foundation/NSString.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -296,27 +296,14 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC
296296
}
297297

298298
internal func _fastCStringContents(_ nullTerminated: Bool) -> UnsafePointer<Int8>? {
299-
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
300-
if _storage._core.isASCII {
301-
return unsafeBitCast(_storage._core.startASCII, to: UnsafePointer<Int8>.self)
302-
}
303-
}
304299
return nil
305300
}
306301

307302
internal var _fastContents: UnsafePointer<UniChar>? {
308-
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
309-
if !_storage._core.isASCII {
310-
return UnsafePointer<UniChar>(_storage._core.startUTF16)
311-
}
312-
}
313303
return nil
314304
}
315305

316306
internal var _encodingCantBeStoredInEightBitCFString: Bool {
317-
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
318-
return !_storage._core.isASCII
319-
}
320307
return false
321308
}
322309

@@ -857,17 +844,6 @@ extension NSString {
857844

858845
public func getCString(_ buffer: UnsafeMutablePointer<Int8>, maxLength maxBufferCount: Int, encoding: UInt) -> Bool {
859846
var used = 0
860-
if type(of: self) == NSString.self || type(of: self) == NSMutableString.self {
861-
if _storage._core.isASCII {
862-
used = min(self.length, maxBufferCount - 1)
863-
_storage._core.startASCII.withMemoryRebound(to: Int8.self,
864-
capacity: used) {
865-
buffer.moveAssign(from: $0, count: used)
866-
}
867-
buffer.advanced(by: used).initialize(to: 0)
868-
return true
869-
}
870-
}
871847
if getBytes(UnsafeMutableRawPointer(buffer), maxLength: maxBufferCount, usedLength: &used, encoding: encoding, options: [], range: NSRange(location: 0, length: self.length), remaining: nil) {
872848
buffer.advanced(by: used).initialize(to: 0)
873849
return true

0 commit comments

Comments
 (0)