Skip to content

Commit 99cc322

Browse files
authored
Merge pull request #17379 from airspeedswift/inlineable-audit
2 parents 381ae3b + 422ff83 commit 99cc322

22 files changed

+148
-148
lines changed

stdlib/public/core/Algorithm.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/// - x: A value to compare.
1717
/// - y: Another value to compare.
1818
/// - Returns: The lesser of `x` and `y`. If `x` is equal to `y`, returns `x`.
19-
@inlinable
19+
@inlinable // protocol-only
2020
public func min<T : Comparable>(_ x: T, _ y: T) -> T {
2121
// In case `x == y` we pick `x`.
2222
// This preserves any pre-existing order in case `T` has identity,
@@ -34,7 +34,7 @@ public func min<T : Comparable>(_ x: T, _ y: T) -> T {
3434
/// - rest: Zero or more additional values.
3535
/// - Returns: The least of all the arguments. If there are multiple equal
3636
/// least arguments, the result is the first one.
37-
@inlinable
37+
@inlinable // protocol-only
3838
public func min<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
3939
var minValue = min(min(x, y), z)
4040
// In case `value == minValue`, we pick `minValue`. See min(_:_:).
@@ -50,7 +50,7 @@ public func min<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
5050
/// - x: A value to compare.
5151
/// - y: Another value to compare.
5252
/// - Returns: The greater of `x` and `y`. If `x` is equal to `y`, returns `y`.
53-
@inlinable
53+
@inlinable // protocol-only
5454
public func max<T : Comparable>(_ x: T, _ y: T) -> T {
5555
// In case `x == y`, we pick `y`. See min(_:_:).
5656
return y >= x ? y : x
@@ -65,7 +65,7 @@ public func max<T : Comparable>(_ x: T, _ y: T) -> T {
6565
/// - rest: Zero or more additional values.
6666
/// - Returns: The greatest of all the arguments. If there are multiple equal
6767
/// greatest arguments, the result is the last one.
68-
@inlinable
68+
@inlinable // protocol-only
6969
public func max<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
7070
var maxValue = max(max(x, y), z)
7171
// In case `value == maxValue`, we pick `value`. See min(_:_:).

stdlib/public/core/Assert.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public func _debugPrecondition(
267267
file: StaticString = #file, line: UInt = #line
268268
) {
269269
// Only check in debug mode.
270-
if _isDebugAssertConfiguration() {
270+
if _slowPath(_isDebugAssertConfiguration()) {
271271
if !_branchHint(condition(), expected: true) {
272272
_fatalErrorMessage("Fatal error", message, file: file, line: line,
273273
flags: _fatalErrorFlags())
@@ -281,7 +281,7 @@ public func _debugPreconditionFailure(
281281
_ message: StaticString = StaticString(),
282282
file: StaticString = #file, line: UInt = #line
283283
) -> Never {
284-
if _isDebugAssertConfiguration() {
284+
if _slowPath(_isDebugAssertConfiguration()) {
285285
_precondition(false, message, file: file, line: line)
286286
}
287287
_conditionallyUnreachable()

stdlib/public/core/BidirectionalCollection.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection {
131131
/// Default implementation for bidirectional collections.
132132
extension BidirectionalCollection {
133133

134-
@inlinable // FIXME(sil-serialize-all)
134+
@inlinable // protocol-only
135135
@inline(__always)
136136
public func formIndex(before i: inout Index) {
137137
i = index(before: i)
138138
}
139139

140-
@inlinable // FIXME(sil-serialize-all)
140+
@inlinable // protocol-only
141141
public func index(_ i: Index, offsetBy n: Int) -> Index {
142142
if n >= 0 {
143143
return _advanceForward(i, by: n)
@@ -149,7 +149,7 @@ extension BidirectionalCollection {
149149
return i
150150
}
151151

152-
@inlinable // FIXME(sil-serialize-all)
152+
@inlinable // protocol-only
153153
public func index(
154154
_ i: Index, offsetBy n: Int, limitedBy limit: Index
155155
) -> Index? {
@@ -166,7 +166,7 @@ extension BidirectionalCollection {
166166
return i
167167
}
168168

169-
@inlinable // FIXME(sil-serialize-all)
169+
@inlinable // protocol-only
170170
public func distance(from start: Index, to end: Index) -> Int {
171171
var start = start
172172
var count = 0
@@ -199,7 +199,7 @@ extension BidirectionalCollection where SubSequence == Self {
199199
/// or more elements; otherwise, `nil`.
200200
///
201201
/// - Complexity: O(1).
202-
@inlinable // FIXME(sil-serialize-all)
202+
@inlinable // protocol-only
203203
public mutating func popLast() -> Element? {
204204
guard !isEmpty else { return nil }
205205
let element = last!
@@ -215,7 +215,7 @@ extension BidirectionalCollection where SubSequence == Self {
215215
/// - Returns: The last element of the collection.
216216
///
217217
/// - Complexity: O(1)
218-
@inlinable // FIXME(sil-serialize-all)
218+
@inlinable // protocol-only
219219
@discardableResult
220220
public mutating func removeLast() -> Element {
221221
let element = last!
@@ -232,7 +232,7 @@ extension BidirectionalCollection where SubSequence == Self {
232232
/// - Complexity: O(1) if the collection conforms to
233233
/// `RandomAccessCollection`; otherwise, O(*n*), where *n* is the length
234234
/// of the collection.
235-
@inlinable // FIXME(sil-serialize-all)
235+
@inlinable // protocol-only
236236
public mutating func removeLast(_ n: Int) {
237237
if n == 0 { return }
238238
_precondition(n >= 0, "Number of elements to remove should be non-negative")
@@ -260,7 +260,7 @@ extension BidirectionalCollection {
260260
/// - Returns: A subsequence that leaves off `n` elements from the end.
261261
///
262262
/// - Complexity: O(*n*), where *n* is the number of elements to drop.
263-
@inlinable // FIXME(sil-serialize-all)
263+
@inlinable // protocol-only
264264
public func dropLast(_ n: Int) -> SubSequence {
265265
_precondition(
266266
n >= 0, "Can't drop a negative number of elements from a collection")
@@ -289,7 +289,7 @@ extension BidirectionalCollection {
289289
/// most `maxLength` elements.
290290
///
291291
/// - Complexity: O(*n*), where *n* is equal to `maxLength`.
292-
@inlinable // FIXME(sil-serialize-all)
292+
@inlinable // protocol-only
293293
public func suffix(_ maxLength: Int) -> SubSequence {
294294
_precondition(
295295
maxLength >= 0,

stdlib/public/core/Builtin.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func _canBeClass<T>(_: T.Type) -> Int8 {
7878
/// - type: The type to cast `x` to. `type` and the type of `x` must have the
7979
/// same size of memory representation and compatible memory layout.
8080
/// - Returns: A new instance of type `U`, cast from `x`.
81-
@inlinable // FIXME(sil-serialize-all)
81+
@inlinable // unsafe-performance
8282
@_transparent
8383
public func unsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
8484
_precondition(MemoryLayout<T>.size == MemoryLayout<U>.size,

stdlib/public/core/ClosedRange.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension ClosedRange {
9696
}
9797

9898
extension ClosedRange: RangeExpression {
99-
@inlinable // FIXME(sil-serialize-all)
99+
@inlinable // trivial-implementation
100100
public func relative<C: Collection>(to collection: C) -> Range<Bound>
101101
where C.Index == Bound {
102102
return Range(
@@ -330,7 +330,7 @@ extension Comparable {
330330
/// - Parameters:
331331
/// - minimum: The lower bound for the range.
332332
/// - maximum: The upper bound for the range.
333-
@inlinable // FIXME(sil-serialize-all)
333+
@inlinable // trivial-implementation
334334
@_transparent
335335
public static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self> {
336336
_precondition(
@@ -362,7 +362,7 @@ extension Strideable where Stride: SignedInteger {
362362
/// - Parameters:)`.
363363
/// - minimum: The lower bound for the range.
364364
/// - maximum: The upper bound for the range.
365-
@inlinable // FIXME(sil-serialize-all)
365+
@inlinable // trivial-implementation
366366
@_transparent
367367
public static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self> {
368368
// FIXME: swift-3-indexing-model: tests for traps.
@@ -404,7 +404,7 @@ extension ClosedRange: Hashable where Bound: Hashable {
404404

405405
extension ClosedRange : CustomStringConvertible {
406406
/// A textual representation of the range.
407-
@inlinable // FIXME(sil-serialize-all)...
407+
@inlinable // trivial-implementation...
408408
public var description: String {
409409
return "\(lowerBound)...\(upperBound)"
410410
}
@@ -444,7 +444,7 @@ extension ClosedRange {
444444
///
445445
/// - Parameter limits: The range to clamp the bounds of this range.
446446
/// - Returns: A new range clamped to the bounds of `limits`.
447-
@inlinable // FIXME(sil-serialize-all)
447+
@inlinable // trivial-implementation
448448
@inline(__always)
449449
public func clamped(to limits: ClosedRange) -> ClosedRange {
450450
let lower =

stdlib/public/core/Collection.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ extension Collection {
804804
///
805805
/// - Parameter i: A valid index of the collection. `i` must be less than
806806
/// `endIndex`.
807-
@inlinable // FIXME(sil-serialize-all)
807+
@inlinable // protocol-only
808808
@inline(__always)
809809
public func formIndex(after i: inout Index) {
810810
i = index(after: i)
@@ -1094,7 +1094,7 @@ extension Collection {
10941094
/// `IndexingIterator<Self>`.
10951095
extension Collection where Iterator == IndexingIterator<Self> {
10961096
/// Returns an iterator over the elements of the collection.
1097-
@inlinable // FIXME(sil-serialize-all)
1097+
@inlinable // trivial-implementation
10981098
@inline(__always)
10991099
public func makeIterator() -> IndexingIterator<Self> {
11001100
return IndexingIterator(_elements: self)

stdlib/public/core/CollectionOfOne.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
/// let toAdd = 100
2222
/// let b = a + CollectionOfOne(toAdd)
2323
/// // b == [1, 2, 3, 4, 100]
24-
@_fixed_layout // FIXME(sil-serialize-all)
24+
@_fixed_layout // trivial-implementation
2525
public struct CollectionOfOne<Element> {
26-
@usableFromInline // FIXME(sil-serialize-all)
26+
@usableFromInline // trivial-implementation
2727
internal var _element: Element
2828

2929
/// Creates an instance containing just the given element.
3030
///
3131
/// - Parameter element: The element to store in the collection.
32-
@inlinable // FIXME(sil-serialize-all)
32+
@inlinable // trivial-implementation
3333
public init(_ element: Element) {
3434
self._element = element
3535
}
@@ -39,14 +39,14 @@ extension CollectionOfOne {
3939
/// An iterator that produces one or zero instances of an element.
4040
///
4141
/// `IteratorOverOne` is the iterator for the `CollectionOfOne` type.
42-
@_fixed_layout // FIXME(sil-serialize-all)
42+
@_fixed_layout // trivial-implementation
4343
public struct Iterator {
44-
@usableFromInline // FIXME(sil-serialize-all)
44+
@usableFromInline // trivial-implementation
4545
internal var _elements: Element?
4646

4747
/// Construct an instance that generates `_element!`, or an empty
4848
/// sequence if `_element == nil`.
49-
@inlinable // FIXME(sil-serialize-all)
49+
@inlinable // trivial-implementation
5050
public // @testable
5151
init(_elements: Element?) {
5252
self._elements = _elements
@@ -62,7 +62,7 @@ extension CollectionOfOne.Iterator: IteratorProtocol {
6262
///
6363
/// - Returns: The next element in the underlying sequence, if a next element
6464
/// exists; otherwise, `nil`.
65-
@inlinable // FIXME(sil-serialize-all)
65+
@inlinable // trivial-implementation
6666
public mutating func next() -> Element? {
6767
let result = _elements
6868
_elements = nil
@@ -88,7 +88,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
8888
/// last valid subscript argument.
8989
///
9090
/// In a `CollectionOfOne` instance, `endIndex` is always `1`.
91-
@inlinable // FIXME(sil-serialize-all)
91+
@inlinable // trivial-implementation
9292
public var endIndex: Index {
9393
return 1
9494
}
@@ -97,7 +97,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
9797
///
9898
/// - Parameter i: A valid index of the collection. `i` must be `0`.
9999
/// - Returns: The index value immediately after `i`.
100-
@inlinable // FIXME(sil-serialize-all)
100+
@inlinable // trivial-implementation
101101
public func index(after i: Index) -> Index {
102102
_precondition(i == startIndex)
103103
return 1
@@ -107,7 +107,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
107107
///
108108
/// - Parameter i: A valid index of the collection. `i` must be `1`.
109109
/// - Returns: The index value immediately before `i`.
110-
@inlinable // FIXME(sil-serialize-all)
110+
@inlinable // trivial-implementation
111111
public func index(before i: Index) -> Index {
112112
_precondition(i == endIndex)
113113
return 0
@@ -116,7 +116,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
116116
/// Returns an iterator over the elements of this collection.
117117
///
118118
/// - Complexity: O(1)
119-
@inlinable // FIXME(sil-serialize-all)
119+
@inlinable // trivial-implementation
120120
public func makeIterator() -> Iterator {
121121
return Iterator(_elements: _element)
122122
}
@@ -125,7 +125,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
125125
///
126126
/// - Parameter position: The position of the element to access. The only
127127
/// valid position in a `CollectionOfOne` instance is `0`.
128-
@inlinable // FIXME(sil-serialize-all)
128+
@inlinable // trivial-implementation
129129
public subscript(position: Int) -> Element {
130130
get {
131131
_precondition(position == 0, "Index out of range")
@@ -137,7 +137,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
137137
}
138138
}
139139

140-
@inlinable // FIXME(sil-serialize-all)
140+
@inlinable // trivial-implementation
141141
public subscript(bounds: Range<Int>) -> SubSequence {
142142
get {
143143
_failEarlyRangeCheck(bounds, bounds: 0..<1)
@@ -152,7 +152,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
152152
}
153153

154154
/// The number of elements in the collection, which is always one.
155-
@inlinable // FIXME(sil-serialize-all)
155+
@inlinable // trivial-implementation
156156
public var count: Int {
157157
return 1
158158
}

stdlib/public/core/Equatable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ extension Equatable {
188188
/// - Parameters:
189189
/// - lhs: A value to compare.
190190
/// - rhs: Another value to compare.
191-
@inlinable // FIXME(sil-serialize-all)
191+
@inlinable // protocol-only
192192
@_transparent
193193
public static func != (lhs: Self, rhs: Self) -> Bool {
194194
return !(lhs == rhs)

stdlib/public/core/Indices.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extension Collection where Indices == DefaultIndices<Self> {
119119
/// i = c.index(after: i)
120120
/// }
121121
/// // c == MyFancyCollection([2, 4, 6, 8, 10])
122-
@inlinable // FIXME(sil-serialize-all)
122+
@inlinable // trivial-implementation
123123
public var indices: DefaultIndices<Self> {
124124
return DefaultIndices(
125125
_elements: self,

stdlib/public/core/LazyCollection.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public protocol LazyCollectionProtocol: Collection, LazySequenceProtocol {
2929

3030
extension LazyCollectionProtocol {
3131
// Lazy things are already lazy
32-
@inlinable // FIXME(sil-serialize-all)
32+
@inlinable // protocol-only
3333
public var lazy: LazyCollection<Elements> {
3434
return elements.lazy
3535
}
3636
}
3737

3838
extension LazyCollectionProtocol where Elements: LazyCollectionProtocol {
3939
// Lazy things are already lazy
40-
@inlinable // FIXME(sil-serialize-all)
40+
@inlinable // protocol-only
4141
public var lazy: Elements {
4242
return elements
4343
}

stdlib/public/core/LazySequence.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ public protocol LazySequenceProtocol : Sequence {
154154
/// property is provided.
155155
extension LazySequenceProtocol where Elements == Self {
156156
/// Identical to `self`.
157-
@inlinable // FIXME(sil-serialize-all)
157+
@inlinable // protocol-only
158158
public var elements: Self { return self }
159159
}
160160

161161
extension LazySequenceProtocol {
162-
@inlinable // FIXME(sil-serialize-all)
162+
@inlinable // protocol-only
163163
public var lazy: LazySequence<Elements> {
164164
return elements.lazy
165165
}
166166
}
167167

168168
extension LazySequenceProtocol where Elements: LazySequenceProtocol {
169-
@inlinable // FIXME(sil-serialize-all)
169+
@inlinable // protocol-only
170170
public var lazy: Elements {
171171
return elements
172172
}
@@ -202,7 +202,7 @@ extension Sequence {
202202
/// A sequence containing the same elements as this sequence,
203203
/// but on which some operations, such as `map` and `filter`, are
204204
/// implemented lazily.
205-
@inlinable // FIXME(sil-serialize-all)
205+
@inlinable // protocol-only
206206
public var lazy: LazySequence<Self> {
207207
return LazySequence(_base: self)
208208
}

stdlib/public/core/RandomAccessCollection.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ where Index : Strideable,
195195
/// - Parameter i: A valid index of the collection. `i` must be greater than
196196
/// `startIndex`.
197197
/// - Returns: The index value immediately before `i`.
198-
@inlinable // FIXME(sil-serialize-all)
198+
@inlinable // protocol-only
199199
public func index(before i: Index) -> Index {
200200
let result = i.advanced(by: -1)
201201
// FIXME: swift-3-indexing-model: tests for the trap.

0 commit comments

Comments
 (0)