Skip to content

Commit bd8459c

Browse files
committed
stdlib: Add some @inline(__always) annotations to make optimizer tests pass when the library is built without -sil-serialize-all
1 parent be1aedb commit bd8459c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

stdlib/public/core/FixedPoint.swift.gyb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,23 @@ extension ${Self} : Hashable {
333333
/// different invocations of the same program. Do not persist the
334334
/// hash value across program runs.
335335
public var hashValue: Int {
336+
@inline(__always)
337+
get {
336338
% if bits <= word_bits and signed:
337-
// Sign extend the value.
338-
return Int(self)
339+
// Sign extend the value.
340+
return Int(self)
339341
% elif bits <= word_bits and not signed:
340-
// Sign extend the value.
341-
return Int(${OtherSelf}(bitPattern: self))
342+
// Sign extend the value.
343+
return Int(${OtherSelf}(bitPattern: self))
342344
% elif bits == word_bits * 2:
343-
// We have twice as many bits as we need to return.
344-
return
345-
Int(truncatingBitPattern: self) ^
346-
Int(truncatingBitPattern: self >> 32)
345+
// We have twice as many bits as we need to return.
346+
return
347+
Int(truncatingBitPattern: self) ^
348+
Int(truncatingBitPattern: self >> 32)
347349
% else:
348-
_Unimplemented()
350+
_Unimplemented()
349351
% end
352+
}
350353
}
351354
}
352355

stdlib/public/core/Range.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public struct RangeIterator<
1616
> : IteratorProtocol, Sequence {
1717

1818
/// Construct an instance that traverses the elements of `bounds`.
19+
@_versioned
1920
@_transparent
2021
internal init(_bounds: Range<Element>) {
2122
self.startIndex = _bounds.startIndex
@@ -24,6 +25,7 @@ public struct RangeIterator<
2425

2526
/// Advance to the next element and return it, or `nil` if no next
2627
/// element exists.
28+
@inline(__always)
2729
public mutating func next() -> Element? {
2830
if startIndex == endIndex { return nil }
2931
let element = startIndex
@@ -115,6 +117,7 @@ public struct Range<
115117
/// Returns an iterator over the elements of this sequence.
116118
///
117119
/// - Complexity: O(1).
120+
@inline(__always)
118121
public func makeIterator() -> RangeIterator<Element> {
119122
return RangeIterator(_bounds: self)
120123
}

0 commit comments

Comments
 (0)