mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Rename _StringCore to _LegacyStringCore. NFC.
In grand LLVM tradition, the first step to redesigning _StringCore is to first rename it to _LegacyStringCore. Subsequent commits will introduce the replacement, and eventually all uses of the old one will be moved to the new one. NFC.
This commit is contained in:
committed by
Michael Ilseman
parent
0ccd5cca6a
commit
75463e30f3
@@ -222,7 +222,7 @@ extension Character
|
||||
default:
|
||||
_representation = Character(
|
||||
_largeRepresentationString: String(
|
||||
_StringCore(
|
||||
_LegacyStringCore(
|
||||
baseAddress: UnsafeMutableRawPointer(start),
|
||||
count: utf16.count,
|
||||
elementShift: 1,
|
||||
@@ -313,9 +313,9 @@ extension Character {
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned
|
||||
internal var _largeUTF16 : _StringCore? {
|
||||
internal var _largeUTF16 : _LegacyStringCore? {
|
||||
guard case .large(let storage) = _representation else { return nil }
|
||||
return _StringCore(_StringBuffer(storage))
|
||||
return _LegacyStringCore(_StringBuffer(storage))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ where Source.Iterator.Element == SourceEncoding.CodeUnit {
|
||||
return try body(a, targetLength)
|
||||
}
|
||||
|
||||
extension _StringCore {
|
||||
extension _LegacyStringCore {
|
||||
/// Invokes `body` on a null-terminated sequence of code units in the given
|
||||
/// encoding corresponding to the substring in `bounds`.
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@@ -290,7 +290,7 @@ extension String {
|
||||
) where C.Iterator.Element == Encoding.CodeUnit {
|
||||
let (b,_) = _StringBuffer.fromCodeUnits(
|
||||
codeUnits, encoding: sourceEncoding, repairIllFormedSequences: true)
|
||||
self = String(_StringCore(b!))
|
||||
self = String(_LegacyStringCore(b!))
|
||||
}
|
||||
|
||||
/// Creates a string from the null-terminated sequence of bytes at the given
|
||||
@@ -681,17 +681,17 @@ public struct String {
|
||||
/// let alsoEmpty = String()
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public init() {
|
||||
_core = _StringCore()
|
||||
_core = _LegacyStringCore()
|
||||
}
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public // @testable
|
||||
init(_ _core: _StringCore) {
|
||||
init(_ _core: _LegacyStringCore) {
|
||||
self._core = _core
|
||||
}
|
||||
|
||||
public // @testable
|
||||
var _core: _StringCore
|
||||
var _core: _LegacyStringCore
|
||||
}
|
||||
|
||||
extension String {
|
||||
@@ -770,7 +770,7 @@ extension String : _ExpressibleByBuiltinUTF16StringLiteral {
|
||||
utf16CodeUnitCount: Builtin.Word
|
||||
) {
|
||||
self = String(
|
||||
_StringCore(
|
||||
_LegacyStringCore(
|
||||
baseAddress: UnsafeMutableRawPointer(start),
|
||||
count: Int(utf16CodeUnitCount),
|
||||
elementShift: 1,
|
||||
@@ -789,7 +789,7 @@ extension String : _ExpressibleByBuiltinStringLiteral {
|
||||
isASCII: Builtin.Int1) {
|
||||
if Bool(isASCII) {
|
||||
self = String(
|
||||
_StringCore(
|
||||
_LegacyStringCore(
|
||||
baseAddress: UnsafeMutableRawPointer(start),
|
||||
count: Int(utf8CodeUnitCount),
|
||||
elementShift: 0,
|
||||
@@ -902,7 +902,7 @@ extension String {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public // SPI(Foundation)
|
||||
init(_storage: _StringBuffer) {
|
||||
_core = _StringCore(_storage)
|
||||
_core = _LegacyStringCore(_storage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func _cocoaStringToSwiftString_NonASCII(
|
||||
let length = _stdlib_binary_CFStringGetLength(cfImmutableValue)
|
||||
let start = _stdlib_binary_CFStringGetCharactersPtr(cfImmutableValue)
|
||||
|
||||
return String(_StringCore(
|
||||
return String(_LegacyStringCore(
|
||||
baseAddress: start,
|
||||
count: length,
|
||||
elementShift: 1,
|
||||
@@ -105,8 +105,8 @@ internal func _cocoaStringReadAll(
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
@inline(never) // Hide the CF dependency
|
||||
internal func _cocoaStringSlice(
|
||||
_ target: _StringCore, _ bounds: Range<Int>
|
||||
) -> _StringCore {
|
||||
_ target: _LegacyStringCore, _ bounds: Range<Int>
|
||||
) -> _LegacyStringCore {
|
||||
_sanityCheck(target.hasCocoaBuffer)
|
||||
|
||||
let cfSelf: _swift_shims_CFStringRef = target.cocoaBuffer.unsafelyUnwrapped
|
||||
@@ -125,7 +125,7 @@ internal func _cocoaStringSlice(
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
@inline(never) // Hide the CF dependency
|
||||
internal func _cocoaStringSubscript(
|
||||
_ target: _StringCore, _ position: Int
|
||||
_ target: _LegacyStringCore, _ position: Int
|
||||
) -> UTF16.CodeUnit {
|
||||
let cfSelf: _swift_shims_CFStringRef = target.cocoaBuffer.unsafelyUnwrapped
|
||||
|
||||
@@ -180,7 +180,7 @@ extension String {
|
||||
start = UnsafeMutableRawPointer(mutating: nulTerminatedASCII)
|
||||
}
|
||||
|
||||
self._core = _StringCore(
|
||||
self._core = _LegacyStringCore(
|
||||
baseAddress: start,
|
||||
count: length,
|
||||
elementShift: isUTF16 ? 1 : 0,
|
||||
@@ -224,7 +224,7 @@ public protocol _NSStringCore :
|
||||
@_fixed_layout // FIXME(sil-serialize-all)
|
||||
public final class _NSContiguousString : _SwiftNativeNSString {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public init(_ _core: _StringCore) {
|
||||
public init(_ _core: _LegacyStringCore) {
|
||||
_sanityCheck(
|
||||
_core.hasContiguousStorage,
|
||||
"_NSContiguousString requires contiguous storage")
|
||||
@@ -352,7 +352,7 @@ public final class _NSContiguousString : _SwiftNativeNSString {
|
||||
return try body(selfAsPointer, rhsAsPointer)
|
||||
}
|
||||
|
||||
public let _core: _StringCore
|
||||
public let _core: _LegacyStringCore
|
||||
}
|
||||
|
||||
extension String {
|
||||
|
||||
@@ -68,10 +68,10 @@ extension String {
|
||||
@_fixed_layout // FIXME(sil-serialize-all)
|
||||
public struct _CharacterView {
|
||||
@_versioned
|
||||
internal var _core: _StringCore
|
||||
internal var _core: _LegacyStringCore
|
||||
|
||||
/// The offset of this view's `_core` from an original core. This works
|
||||
/// around the fact that `_StringCore` is always zero-indexed.
|
||||
/// around the fact that `_LegacyStringCore` is always zero-indexed.
|
||||
/// `_coreOffset` should be subtracted from `UnicodeScalarIndex.encodedOffset`
|
||||
/// before that value is used as a `_core` index.
|
||||
@_versioned
|
||||
@@ -86,7 +86,7 @@ extension String {
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public // @testable
|
||||
init(_ _core: _StringCore, coreOffset: Int = 0) {
|
||||
init(_ _core: _LegacyStringCore, coreOffset: Int = 0) {
|
||||
self._core = _core
|
||||
self._coreOffset = coreOffset
|
||||
}
|
||||
@@ -189,7 +189,7 @@ extension String._CharacterView : _SwiftStringView {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _persistentContent : String {
|
||||
// FIXME: we might want to make sure our _StringCore isn't somehow a slice
|
||||
// FIXME: we might want to make sure our _LegacyStringCore isn't somehow a slice
|
||||
// of some larger storage before blindly wrapping/returning it as
|
||||
// persistent. That said, if current benchmarks are measuring these cases,
|
||||
// we might end up regressing something by copying the storage. For now,
|
||||
@@ -385,7 +385,7 @@ extension String._CharacterView : BidirectionalCollection {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Our relative offset from the _StringCore's baseAddress pointer. If our
|
||||
// Our relative offset from the _LegacyStringCore's baseAddress pointer. If our
|
||||
// _core is not a substring, this is the same as start.encodedOffset. Otherwise,
|
||||
// it is the code unit relative offset into the substring and not the
|
||||
// absolute offset into the outer string.
|
||||
@@ -522,7 +522,7 @@ extension String._CharacterView : BidirectionalCollection {
|
||||
return 1
|
||||
}
|
||||
|
||||
// The relative offset from the _StringCore's baseAddress pointer for the
|
||||
// The relative offset from the _LegacyStringCore's baseAddress pointer for the
|
||||
// one-past-the-end and the last code unit under consideration. If our
|
||||
// _core is not a substring, these are the same as positions. Otherwise,
|
||||
// these are code unit relative offsets into the substring and not the
|
||||
@@ -569,7 +569,7 @@ extension String._CharacterView : BidirectionalCollection {
|
||||
let startOffset = 0
|
||||
let numCodeUnits = endOffset - startOffset
|
||||
_sanityCheck(unicodeScalars.startIndex.encodedOffset - _coreOffset == 0,
|
||||
"position/offset mismatch in _StringCore as a substring")
|
||||
"position/offset mismatch in _LegacyStringCore as a substring")
|
||||
_sanityCheck(numCodeUnits >= 2,
|
||||
"should have at least two code units")
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// extra element requirement for 8 bit elements. See the
|
||||
// implementation of subscript(Int) -> UTF16.CodeUnit below for details.
|
||||
@_fixed_layout
|
||||
public struct _StringCore {
|
||||
public struct _LegacyStringCore {
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Internals
|
||||
public var _baseAddress: UnsafeMutableRawPointer?
|
||||
@@ -72,7 +72,7 @@ public struct _StringCore {
|
||||
else if let buffer = nativeBuffer {
|
||||
_sanityCheck(!hasCocoaBuffer)
|
||||
_sanityCheck(elementWidth == buffer.elementWidth,
|
||||
"_StringCore elementWidth doesn't match its buffer's")
|
||||
"_LegacyStringCore elementWidth doesn't match its buffer's")
|
||||
_sanityCheck(_baseAddress! >= buffer.start)
|
||||
_sanityCheck(_baseAddress! <= buffer.usedEnd)
|
||||
_sanityCheck(_pointer(toElementAt: count) <= buffer.usedEnd)
|
||||
@@ -177,11 +177,11 @@ public struct _StringCore {
|
||||
_invariantCheck()
|
||||
}
|
||||
|
||||
/// Create a _StringCore that covers the entire length of the _StringBuffer.
|
||||
/// Create a _LegacyStringCore that covers the entire length of the _StringBuffer.
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ buffer: _StringBuffer) {
|
||||
self = _StringCore(
|
||||
self = _LegacyStringCore(
|
||||
baseAddress: buffer.start,
|
||||
count: buffer.usedCount,
|
||||
elementShift: buffer.elementShift,
|
||||
@@ -302,9 +302,9 @@ public struct _StringCore {
|
||||
//===--------------------------------------------------------------------===//
|
||||
// slicing
|
||||
|
||||
/// Returns the given sub-`_StringCore`.
|
||||
/// Returns the given sub-`_LegacyStringCore`.
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public subscript(bounds: Range<Int>) -> _StringCore {
|
||||
public subscript(bounds: Range<Int>) -> _LegacyStringCore {
|
||||
_precondition(
|
||||
bounds.lowerBound >= 0,
|
||||
"subscript: subrange start precedes String start")
|
||||
@@ -317,7 +317,7 @@ public struct _StringCore {
|
||||
_sanityCheck(UInt(newCount) & _flagMask == 0)
|
||||
|
||||
if hasContiguousStorage {
|
||||
return _StringCore(
|
||||
return _LegacyStringCore(
|
||||
baseAddress: _pointer(toElementAt: bounds.lowerBound),
|
||||
_countAndFlags: (_countAndFlags & _flagMask) | UInt(newCount),
|
||||
owner: _owner)
|
||||
@@ -434,7 +434,7 @@ public struct _StringCore {
|
||||
}
|
||||
else if hasCocoaBuffer {
|
||||
#if _runtime(_ObjC)
|
||||
_StringCore(
|
||||
_LegacyStringCore(
|
||||
_cocoaStringToContiguous(
|
||||
source: cocoaBuffer!, range: 0..<count, minimumCapacity: 0)
|
||||
).encode(encoding, into: processCodeUnit)
|
||||
@@ -467,7 +467,7 @@ public struct _StringCore {
|
||||
) {
|
||||
var buffer = nativeBuffer!
|
||||
|
||||
// In order to grow the substring in place, this _StringCore should point
|
||||
// In order to grow the substring in place, this _LegacyStringCore should point
|
||||
// at the substring at the end of a _StringBuffer. Otherwise, some other
|
||||
// String is using parts of the buffer beyond our last byte.
|
||||
let usedEnd = _pointer(toElementAt:count)
|
||||
@@ -536,7 +536,7 @@ public struct _StringCore {
|
||||
elementWidth: newElementWidth)
|
||||
|
||||
if hasContiguousStorage {
|
||||
_StringCore._copyElements(
|
||||
_LegacyStringCore._copyElements(
|
||||
_baseAddress!, srcElementWidth: elementWidth,
|
||||
dstStart: UnsafeMutableRawPointer(newStorage.start),
|
||||
dstElementWidth: newElementWidth, count: oldCount)
|
||||
@@ -555,7 +555,7 @@ public struct _StringCore {
|
||||
#endif
|
||||
}
|
||||
|
||||
self = _StringCore(newStorage)
|
||||
self = _LegacyStringCore(newStorage)
|
||||
}
|
||||
|
||||
/// Append `c` to `self`.
|
||||
@@ -611,7 +611,7 @@ public struct _StringCore {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
@inline(never)
|
||||
internal mutating func append(_ rhs: _StringCore) {
|
||||
internal mutating func append(_ rhs: _LegacyStringCore) {
|
||||
_invariantCheck()
|
||||
let minElementWidth
|
||||
= elementWidth >= rhs.elementWidth
|
||||
@@ -622,7 +622,7 @@ public struct _StringCore {
|
||||
count + rhs.count, minElementWidth: minElementWidth)
|
||||
|
||||
if _fastPath(rhs.hasContiguousStorage) {
|
||||
_StringCore._copyElements(
|
||||
_LegacyStringCore._copyElements(
|
||||
rhs._baseAddress!, srcElementWidth: rhs.elementWidth,
|
||||
dstStart: destination, dstElementWidth:elementWidth, count: rhs.count)
|
||||
}
|
||||
@@ -659,7 +659,7 @@ public struct _StringCore {
|
||||
}
|
||||
}
|
||||
|
||||
extension _StringCore : RandomAccessCollection {
|
||||
extension _LegacyStringCore : RandomAccessCollection {
|
||||
|
||||
public typealias Indices = CountableRange<Int>
|
||||
|
||||
@@ -676,7 +676,7 @@ extension _StringCore : RandomAccessCollection {
|
||||
}
|
||||
}
|
||||
|
||||
extension _StringCore : RangeReplaceableCollection {
|
||||
extension _LegacyStringCore : RangeReplaceableCollection {
|
||||
|
||||
/// Replace the elements within `bounds` with `newElements`.
|
||||
///
|
||||
@@ -743,7 +743,7 @@ extension _StringCore : RangeReplaceableCollection {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var r = _StringCore(
|
||||
var r = _LegacyStringCore(
|
||||
_StringBuffer(
|
||||
capacity: newCount,
|
||||
initialSize: 0,
|
||||
|
||||
@@ -258,13 +258,13 @@ extension String {
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ _core: _StringCore) {
|
||||
internal init(_ _core: _LegacyStringCore) {
|
||||
self.init(_core, offset: 0, length: _core.count)
|
||||
}
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ _core: _StringCore, offset: Int, length: Int) {
|
||||
internal init(_ _core: _LegacyStringCore, offset: Int, length: Int) {
|
||||
self._offset = offset
|
||||
self._length = length
|
||||
self._core = _core
|
||||
@@ -287,7 +287,7 @@ extension String {
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _length: Int
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal let _core: _StringCore
|
||||
internal let _core: _LegacyStringCore
|
||||
}
|
||||
|
||||
/// A UTF-16 encoding of `self`.
|
||||
@@ -327,7 +327,7 @@ extension String {
|
||||
// semantics may be impossible to preserve in the case of string literals,
|
||||
// since we no longer have access to the length of the original string when
|
||||
// there is no owner and elements are dropped from the end.
|
||||
let wholeString = utf16._core.nativeBuffer.map { String(_StringCore($0)) }
|
||||
let wholeString = utf16._core.nativeBuffer.map { String(_LegacyStringCore($0)) }
|
||||
?? String(utf16._core)
|
||||
|
||||
guard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- StringUTF8.swift - A UTF8 view of _StringCore --------------------===//
|
||||
//===--- StringUTF8.swift - A UTF8 view of _LegacyStringCore --------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// _StringCore currently has three representations: Native ASCII,
|
||||
// _LegacyStringCore currently has three representations: Native ASCII,
|
||||
// Native UTF-16, and Opaque Cocoa. Expose each of these as UTF-8 in a
|
||||
// way that will hopefully be efficient to traverse
|
||||
//
|
||||
@@ -99,7 +99,7 @@ extension String {
|
||||
|
||||
/// Underlying UTF-16-compatible representation
|
||||
@_versioned
|
||||
internal let _core: _StringCore
|
||||
internal let _core: _LegacyStringCore
|
||||
|
||||
/// Distances to `(startIndex, endIndex)` from the endpoints of _core,
|
||||
/// measured in UTF-8 code units.
|
||||
@@ -112,7 +112,7 @@ extension String {
|
||||
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ _core: _StringCore,
|
||||
internal init(_ _core: _LegacyStringCore,
|
||||
legacyOffsets: (Int, Int) = (0, 0)
|
||||
) {
|
||||
self._core = _core
|
||||
@@ -423,7 +423,7 @@ extension String {
|
||||
// since we no longer have access to the length of the original string when
|
||||
// there is no owner and elements have been dropped from the end.
|
||||
if let nativeBuffer = utf8._core.nativeBuffer {
|
||||
let wholeString = String(_StringCore(nativeBuffer))
|
||||
let wholeString = String(_LegacyStringCore(nativeBuffer))
|
||||
let offset = (utf8._core._baseAddress! - nativeBuffer.start)
|
||||
&>> utf8._core.elementShift
|
||||
|
||||
@@ -462,7 +462,7 @@ extension String.UTF8View {
|
||||
public struct Iterator {
|
||||
internal typealias _OutputBuffer = UInt64
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal let _source: _StringCore
|
||||
internal let _source: _LegacyStringCore
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _sourceIndex: Int
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
@@ -476,7 +476,7 @@ extension String.UTF8View {
|
||||
extension String.UTF8View.Iterator : IteratorProtocol {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ source: _StringCore) {
|
||||
internal init(_ source: _LegacyStringCore) {
|
||||
_source = source
|
||||
_sourceIndex = 0
|
||||
_buffer = 0
|
||||
|
||||
@@ -65,7 +65,7 @@ extension String {
|
||||
{
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ _core: _StringCore, coreOffset: Int = 0) {
|
||||
internal init(_ _core: _LegacyStringCore, coreOffset: Int = 0) {
|
||||
self._core = _core
|
||||
self._coreOffset = coreOffset
|
||||
}
|
||||
@@ -74,12 +74,12 @@ extension String {
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal struct _ScratchIterator : IteratorProtocol {
|
||||
@_versioned
|
||||
internal var core: _StringCore
|
||||
internal var core: _LegacyStringCore
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var idx: Int
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ core: _StringCore, _ pos: Int) {
|
||||
internal init(_ core: _LegacyStringCore, _ pos: Int) {
|
||||
self.idx = pos
|
||||
self.core = core
|
||||
}
|
||||
@@ -194,7 +194,7 @@ extension String {
|
||||
public struct Iterator : IteratorProtocol {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal init(_ _base: _StringCore) {
|
||||
internal init(_ _base: _LegacyStringCore) {
|
||||
self._iterator = _base.makeIterator()
|
||||
if _base.hasContiguousStorage {
|
||||
self._baseSet = true
|
||||
@@ -261,7 +261,7 @@ extension String {
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _base: UnsafeBufferPointer<UInt16>.Iterator!
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _iterator: IndexingIterator<_StringCore>
|
||||
internal var _iterator: IndexingIterator<_LegacyStringCore>
|
||||
}
|
||||
|
||||
/// Returns an iterator over the Unicode scalars that make up this view.
|
||||
@@ -283,10 +283,10 @@ extension String {
|
||||
}
|
||||
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
internal var _core: _StringCore
|
||||
internal var _core: _LegacyStringCore
|
||||
|
||||
/// The offset of this view's `_core` from an original core. This works
|
||||
/// around the fact that `_StringCore` is always zero-indexed.
|
||||
/// around the fact that `_LegacyStringCore` is always zero-indexed.
|
||||
/// `_coreOffset` should be subtracted from `UnicodeScalarIndex.encodedOffset`
|
||||
/// before that value is used as a `_core` index.
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
@@ -342,7 +342,7 @@ extension String.UnicodeScalarView : RangeReplaceableCollection {
|
||||
/// Creates an empty view instance.
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
public init() {
|
||||
self = String.UnicodeScalarView(_StringCore())
|
||||
self = String.UnicodeScalarView(_LegacyStringCore())
|
||||
}
|
||||
|
||||
/// Reserves enough space in the view's underlying storage to store the
|
||||
|
||||
@@ -26,7 +26,7 @@ extension String {
|
||||
let u16 = x._core[start.encodedOffset..<end.encodedOffset]
|
||||
if start.samePosition(in: x.unicodeScalars) != nil
|
||||
&& end.samePosition(in: x.unicodeScalars) != nil {
|
||||
self = String(_StringCore(u16))
|
||||
self = String(_LegacyStringCore(u16))
|
||||
}
|
||||
else {
|
||||
self = String(decoding: u16, as: UTF16.self)
|
||||
@@ -338,7 +338,7 @@ extension Substring : _SwiftStringView {
|
||||
public // @testable
|
||||
var _ephemeralContent: String {
|
||||
let wholeCore = _wholeString._core
|
||||
let subCore : _StringCore = wholeCore[
|
||||
let subCore : _LegacyStringCore = wholeCore[
|
||||
startIndex.encodedOffset..<endIndex.encodedOffset]
|
||||
// Check that we haven't allocated a new buffer for the result, if we have
|
||||
// contiguous storage.
|
||||
|
||||
@@ -85,7 +85,7 @@ internal struct _ThreadLocalStorage {
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@_versioned // FIXME(sil-serialize-all)
|
||||
static internal func getUBreakIterator(
|
||||
for core: _StringCore
|
||||
for core: _LegacyStringCore
|
||||
) -> OpaquePointer {
|
||||
_sanityCheck(core._owner != nil || core._baseAddress != nil,
|
||||
"invalid StringCore")
|
||||
|
||||
@@ -221,12 +221,12 @@ _TTSg5Si___TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_clo
|
||||
_TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_dT__XFo_iSi_dT__ ---> function signature specialization <Arg[0] = [Constant Propagated Function : capturep.helper(Swift.Int) -> ()]> of reabstraction thunk helper from @callee_owned (@unowned Swift.Int) -> (@unowned ()) to @callee_owned (@in Swift.Int) -> (@unowned ())
|
||||
_TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_DT__XFo_iSi_DT__ ---> function signature specialization <Arg[0] = [Constant Propagated Function : capturep.helper(Swift.Int) -> ()]> of reabstraction thunk helper from @callee_owned (@unowned Swift.Int) -> (@unowned_inner_pointer ()) to @callee_owned (@in Swift.Int) -> (@unowned_inner_pointer ())
|
||||
_TTSf1cpi0_cpfl0_cpse0v4u123_cpg53globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8_cpfr36_TFtest_capture_propagation2_closure___TF7specgen12take_closureFFTSiSi_T_T_ ---> function signature specialization <Arg[0] = [Constant Propagated Integer : 0], Arg[1] = [Constant Propagated Float : 0], Arg[2] = [Constant Propagated String : u8'u123'], Arg[3] = [Constant Propagated Global : globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8], Arg[4] = [Constant Propagated Function : _TFtest_capture_propagation2_closure]> of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> ()
|
||||
_TTSf0gs___TFVs11_StringCore15_invariantCheckfT_T_ ---> function signature specialization <Arg[0] = Owned To Guaranteed and Exploded> of Swift._StringCore._invariantCheck() -> ()
|
||||
_TTSf2g___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Owned To Guaranteed> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._StringCore.init(Swift._StringBuffer) -> Swift._StringCore
|
||||
_TTSf2dg___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead and Owned To Guaranteed> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._StringCore.init(Swift._StringBuffer) -> Swift._StringCore
|
||||
_TTSf2dgs___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead and Owned To Guaranteed and Exploded> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._StringCore.init(Swift._StringBuffer) -> Swift._StringCore
|
||||
_TTSf3d_i_d_i_d_i___TFVs11_StringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead, Arg[1] = Value Promoted from Box, Arg[2] = Dead, Arg[3] = Value Promoted from Box, Arg[4] = Dead, Arg[5] = Value Promoted from Box> of Swift._StringCore.init(Swift._StringBuffer) -> Swift._StringCore
|
||||
_TTSf3d_i_n_i_d_i___TFVs11_StringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead, Arg[1] = Value Promoted from Box, Arg[3] = Value Promoted from Box, Arg[4] = Dead, Arg[5] = Value Promoted from Box> of Swift._StringCore.init(Swift._StringBuffer) -> Swift._StringCore
|
||||
_TTSf0gs___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> function signature specialization <Arg[0] = Owned To Guaranteed and Exploded> of Swift._LegacyStringCore._invariantCheck() -> ()
|
||||
_TTSf2g___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Owned To Guaranteed> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore
|
||||
_TTSf2dg___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead and Owned To Guaranteed> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore
|
||||
_TTSf2dgs___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead and Owned To Guaranteed and Exploded> of function signature specialization <Arg[0] = Exploded, Arg[1] = Dead> of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore
|
||||
_TTSf3d_i_d_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead, Arg[1] = Value Promoted from Box, Arg[2] = Dead, Arg[3] = Value Promoted from Box, Arg[4] = Dead, Arg[5] = Value Promoted from Box> of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore
|
||||
_TTSf3d_i_n_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization <Arg[0] = Dead, Arg[1] = Value Promoted from Box, Arg[3] = Value Promoted from Box, Arg[4] = Dead, Arg[5] = Value Promoted from Box> of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore
|
||||
_TFIZvV8mangling10HasVarInit5stateSbiu_KT_Sb ---> implicit closure #1 : @autoclosure () -> Swift.Bool in variable initialization expression of static mangling.HasVarInit.state : Swift.Bool
|
||||
_TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3fooFTqd__x_T_ ---> foo #1 (A1, A) -> () in interface_type_mangling.GenericTypeContext.closureInGenericContext<A>(A1) -> ()
|
||||
_TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3fooFT_x ---> foo #1 () -> A in interface_type_mangling.GenericTypeContext.closureInGenericPropertyContext.getter : A
|
||||
|
||||
@@ -182,12 +182,12 @@ _TTSg5Si___TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_clo
|
||||
_TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_dT__XFo_iSi_dT__ ---> specialized thunk for @callee_owned (@unowned Int) -> (@unowned ())
|
||||
_TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_DT__XFo_iSi_DT__ ---> specialized thunk for @callee_owned (@unowned Int) -> (@unowned_inner_pointer ())
|
||||
_TTSf1cpi0_cpfl0_cpse0v4u123_cpg53globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8_cpfr36_TFtest_capture_propagation2_closure___TF7specgen12take_closureFFTSiSi_T_T_ ---> specialized take_closure(_:)
|
||||
_TTSf0gs___TFVs11_StringCore15_invariantCheckfT_T_ ---> specialized _StringCore._invariantCheck()
|
||||
_TTSf2g___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> specialized _StringCore.init(_:)
|
||||
_TTSf2dg___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> specialized _StringCore.init(_:)
|
||||
_TTSf2dgs___TTSf2s_d___TFVs11_StringCoreCfVs13_StringBufferS_ ---> specialized _StringCore.init(_:)
|
||||
_TTSf3d_i_d_i_d_i___TFVs11_StringCoreCfVs13_StringBufferS_ ---> specialized _StringCore.init(_:)
|
||||
_TTSf3d_i_n_i_d_i___TFVs11_StringCoreCfVs13_StringBufferS_ ---> specialized _StringCore.init(_:)
|
||||
_TTSf0gs___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> specialized _LegacyStringCore._invariantCheck()
|
||||
_TTSf2g___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:)
|
||||
_TTSf2dg___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:)
|
||||
_TTSf2dgs___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:)
|
||||
_TTSf3d_i_d_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:)
|
||||
_TTSf3d_i_n_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:)
|
||||
_TFIZvV8mangling10HasVarInit5stateSbiu_KT_Sb ---> implicit closure #1 in variable initialization expression of static HasVarInit.state
|
||||
_TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3fooFTqd__x_T_ ---> foo #1 (_:_:) in GenericTypeContext.closureInGenericContext<A>(_:)
|
||||
_TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3fooFT_x ---> foo #1 () in GenericTypeContext.closureInGenericPropertyContext.getter
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// CHECK-NOT: {{^}}import
|
||||
// CHECK-NOT: _Double
|
||||
// CHECK-NOT: _StringBuffer
|
||||
// CHECK-NOT: _StringCore
|
||||
// CHECK-NOT: _LegacyStringCore
|
||||
// CHECK-NOT: _ArrayBody
|
||||
// DONT_CHECK-NOT: {{([^I]|$)([^n]|$)([^d]|$)([^e]|$)([^x]|$)([^a]|$)([^b]|$)([^l]|$)([^e]|$)}}
|
||||
// CHECK-NOT: buffer: _ArrayBuffer
|
||||
|
||||
@@ -19,18 +19,18 @@ class ZZZ {
|
||||
|
||||
class C {}
|
||||
|
||||
sil @stringcore_invariant_check : $@convention(thin) (@owned _StringCore) -> @owned Optional<_CocoaString>
|
||||
sil @stringcore_invariant_check : $@convention(thin) (@owned _LegacyStringCore) -> @owned Optional<_CocoaString>
|
||||
sil @reabstraction_thunk : $@convention(thin) (@owned @callee_owned () -> @owned Optional<_CocoaString>) -> @out Optional<_CocoaString>
|
||||
|
||||
// CHECK-LABEL: sil @dead_closure_elimination : $@convention(thin) (@owned _StringCore) -> ()
|
||||
// CHECK-LABEL: sil @dead_closure_elimination : $@convention(thin) (@owned _LegacyStringCore) -> ()
|
||||
// CHECK: bb0
|
||||
// CHECK-NEXT: release_value
|
||||
// CHECK-NEXT: tuple
|
||||
// CHECK-NEXT: return
|
||||
sil @dead_closure_elimination : $@convention(thin) (@owned _StringCore) -> () {
|
||||
bb0(%0 : $_StringCore):
|
||||
%1 = function_ref @stringcore_invariant_check : $@convention(thin) (@owned _StringCore) -> @owned Optional<_CocoaString>
|
||||
%2 = partial_apply %1(%0) : $@convention(thin) (@owned _StringCore) -> @owned Optional<_CocoaString>
|
||||
sil @dead_closure_elimination : $@convention(thin) (@owned _LegacyStringCore) -> () {
|
||||
bb0(%0 : $_LegacyStringCore):
|
||||
%1 = function_ref @stringcore_invariant_check : $@convention(thin) (@owned _LegacyStringCore) -> @owned Optional<_CocoaString>
|
||||
%2 = partial_apply %1(%0) : $@convention(thin) (@owned _LegacyStringCore) -> @owned Optional<_CocoaString>
|
||||
%3 = function_ref @reabstraction_thunk : $@convention(thin) (@owned @callee_owned () -> @owned Optional<_CocoaString>) -> @out Optional<_CocoaString>
|
||||
%4 = partial_apply %3(%2) : $@convention(thin) (@owned @callee_owned () -> @owned Optional<_CocoaString>) -> @out Optional<_CocoaString>
|
||||
strong_release %4 : $@callee_owned () -> @out Optional<_CocoaString>
|
||||
@@ -45,10 +45,10 @@ bb0(%0 : $_StringCore):
|
||||
// CHECK-NEXT: release_value
|
||||
// CHECK-NEXT: tuple
|
||||
// CHECK-NEXT: return
|
||||
sil @dead_closure_elimination2 : $@convention(thin) (@owned _StringCore) -> () {
|
||||
bb0(%0 : $_StringCore):
|
||||
%1 = function_ref @stringcore_invariant_check : $@convention(thin) (@owned _StringCore) -> @owned Optional<_CocoaString>
|
||||
%2 = partial_apply %1(%0) : $@convention(thin) (@owned _StringCore) -> @owned Optional<_CocoaString>
|
||||
sil @dead_closure_elimination2 : $@convention(thin) (@owned _LegacyStringCore) -> () {
|
||||
bb0(%0 : $_LegacyStringCore):
|
||||
%1 = function_ref @stringcore_invariant_check : $@convention(thin) (@owned _LegacyStringCore) -> @owned Optional<_CocoaString>
|
||||
%2 = partial_apply %1(%0) : $@convention(thin) (@owned _LegacyStringCore) -> @owned Optional<_CocoaString>
|
||||
%3 = function_ref @reabstraction_thunk : $@convention(thin) (@owned @callee_owned () -> @owned Optional<_CocoaString>) -> @out Optional<_CocoaString>
|
||||
%4 = partial_apply %3(%2) : $@convention(thin) (@owned @callee_owned () -> @owned Optional<_CocoaString>) -> @out Optional<_CocoaString>
|
||||
br bb1
|
||||
|
||||
@@ -33,7 +33,7 @@ func repr(_ x: NSString) -> String {
|
||||
return "\(NSStringFromClass(object_getClass(x)))\(hexAddrVal(x)) = \"\(x)\""
|
||||
}
|
||||
|
||||
func repr(_ x: _StringCore) -> String {
|
||||
func repr(_ x: _LegacyStringCore) -> String {
|
||||
if x.hasContiguousStorage {
|
||||
if let b = x.nativeBuffer {
|
||||
var offset = x.elementWidth == 2
|
||||
|
||||
@@ -35,7 +35,7 @@ func repr(_ x: NSString) -> String {
|
||||
return "\(NSStringFromClass(object_getClass(x)))\(hexAddr(x)) = \"\(x)\""
|
||||
}
|
||||
|
||||
func repr(_ x: _StringCore) -> String {
|
||||
func repr(_ x: _LegacyStringCore) -> String {
|
||||
if x.hasContiguousStorage {
|
||||
if let b = x.nativeBuffer {
|
||||
let offset = x.elementWidth == 2
|
||||
|
||||
@@ -823,8 +823,8 @@ StringTests.test("stringCoreReserve")
|
||||
#endif
|
||||
}
|
||||
|
||||
func makeStringCore(_ base: String) -> _StringCore {
|
||||
var x = _StringCore()
|
||||
func makeStringCore(_ base: String) -> _LegacyStringCore {
|
||||
var x = _LegacyStringCore()
|
||||
// make sure some - but not all - replacements will have to grow the buffer
|
||||
x.reserveCapacity(base._core.count * 3 / 2)
|
||||
x.append(contentsOf: base._core)
|
||||
|
||||
Reference in New Issue
Block a user