Skip to content

[String] Expunge _StringGutsSlice from ABI #20812

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
Nov 28, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 3 additions & 7 deletions stdlib/public/core/StringGutsSlice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,18 @@

// A sliced _StringGuts, convenient for unifying String/Substring comparison,
// hashing, and RRC.
@_fixed_layout
@usableFromInline
internal struct _StringGutsSlice {
@usableFromInline
internal var _guts: _StringGuts

@usableFromInline
internal var _offsetRange: Range<Int>

@inlinable @inline(__always)
@inline(__always)
internal init(_ guts: _StringGuts) {
self._guts = guts
self._offsetRange = 0..<self._guts.count
}

@inlinable @inline(__always)
@inline(__always)
internal init(_ guts: _StringGuts, _ offsetRange: Range<Int>) {
self._guts = guts
self._offsetRange = offsetRange
Expand Down Expand Up @@ -83,7 +79,7 @@ internal struct _StringGutsSlice {
}
}

@inlinable @inline(__always)
@inline(__always)
internal func withFastUTF8<R>(
_ f: (UnsafeBufferPointer<UInt8>) throws -> R
) rethrows -> R {
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/StringHashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ extension StringProtocol {
}

extension _StringGutsSlice {
@usableFromInline // @opaque
@inline(never) // slow-path
internal func _normalizedHash(into hasher: inout Hasher) {
if self.isNFCFastUTF8 {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/StringProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ extension StringProtocol {
get { return String(self) }
}

@inlinable // Eliminate for String, Substring
internal var _gutsSlice: _StringGutsSlice {
@_specialize(where Self == String)
@_specialize(where Self == Substring)
Expand All @@ -152,7 +151,8 @@ extension StringProtocol {
@inline(__always) get {
let start = startIndex
let end = endIndex
_internalInvariant(start.transcodedOffset == 0 && end.transcodedOffset == 0)
_internalInvariant(
start.transcodedOffset == 0 && end.transcodedOffset == 0)
return Range(uncheckedBounds: (start.encodedOffset, end.encodedOffset))
}
}
Expand Down
17 changes: 17 additions & 0 deletions test/api-digester/Outputs/stability-stdlib-abi.swift.expected
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,23 @@ Protocol _NSEnumerator has been removed
Protocol _NSFastEnumeration has been removed
Protocol _ShadowProtocol has been removed

Constructor _StringGutsSlice.init(_:) has been removed
Constructor _StringGutsSlice.init(_:_:) has been removed
Func _StringGutsSlice._normalizedHash(into:) has been removed
Func _StringGutsSlice.compare(with:expecting:) has been removed
Func _StringGutsSlice.withFastUTF8(_:) has been removed
Struct _StringGutsSlice is now without @_fixed_layout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is suspicious; it should just say "Struct _StringGutsSlice has been removed".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Could be an API digester bug with handling of @usableFromInline, since the declaration is internal.

Var StringProtocol._gutsSlice has been removed
Var _StringGutsSlice._guts has been removed
Var _StringGutsSlice._offsetRange has been removed
Var _StringGutsSlice.count has been removed
Var _StringGutsSlice.end has been removed
Var _StringGutsSlice.isASCII has been removed
Var _StringGutsSlice.isFastUTF8 has been removed
Var _StringGutsSlice.isNFCFastUTF8 has been removed
Var _StringGutsSlice.range has been removed
Var _StringGutsSlice.start has been removed

Func ManagedBufferPointer._sanityCheckValidBufferClass(_:creating:) has been removed
Func _sanityCheck(_:_:file:line:) has been removed
Func _sanityCheckFailure(_:file:line:) has been removed
Expand Down