Skip to content

Commit db5c967

Browse files
authored
Merge pull request #11545 from swiftix/perf-improvements-for-stdlib-issues
A couple of small improvements for the resilient builds of the stdlib
2 parents 5be80f1 + 7627319 commit db5c967

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

stdlib/public/core/Comparable.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ extension Comparable {
183183
/// - Parameters:
184184
/// - lhs: A value to compare.
185185
/// - rhs: Another value to compare.
186+
@_inlineable
186187
public static func > (lhs: Self, rhs: Self) -> Bool {
187188
return rhs < lhs
188189
}
@@ -196,6 +197,7 @@ extension Comparable {
196197
/// - Parameters:
197198
/// - lhs: A value to compare.
198199
/// - rhs: Another value to compare.
200+
@_inlineable
199201
public static func <= (lhs: Self, rhs: Self) -> Bool {
200202
return !(rhs < lhs)
201203
}
@@ -211,6 +213,7 @@ extension Comparable {
211213
/// - rhs: Another value to compare.
212214
/// - Returns: `true` if `lhs` is greater than or equal to `rhs`; otherwise,
213215
/// `false`.
216+
@_inlineable
214217
public static func >= (lhs: Self, rhs: Self) -> Bool {
215218
return !(lhs < rhs)
216219
}

stdlib/public/core/DoubleWidth.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ public struct DoubleWidth<Base : FixedWidthInteger> :
297297
return (result, didCarry || hadPositiveOverflow)
298298
}
299299

300+
// Specialize for the most popular types.
301+
@_specialize(where Base == Int)
302+
@_specialize(where Base == UInt)
303+
@_specialize(where Base == Int64)
304+
@_specialize(where Base == UInt64)
300305
public func quotientAndRemainder(dividingBy other: DoubleWidth)
301306
-> (quotient: DoubleWidth, remainder: DoubleWidth) {
302307
let isNegative = (self < (0 as DoubleWidth)) != (other < (0 as DoubleWidth))

stdlib/public/core/Integers.swift.gyb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,7 @@ ${operatorComment(x.operator, False)}
16331633
// Heterogeneous non-masking shift in terms of shift-assignment
16341634
${operatorComment(x.nonMaskingOperator, False)}
16351635
@_semantics("optimize.sil.specialize.generic.partial.never")
1636+
@_inlineable
16361637
public static func ${x.nonMaskingOperator}<RHS: BinaryInteger>(
16371638
_ lhs: Self, _ rhs: RHS
16381639
) -> Self {
@@ -2184,6 +2185,7 @@ ${operatorComment(x.operator, False)}
21842185
// Heterogeneous masking shift
21852186
${operatorComment(x.operator, False)}
21862187
@_semantics("optimize.sil.specialize.generic.partial.never")
2188+
@_inlineable
21872189
public static func ${x.operator} <
21882190
Other : BinaryInteger
21892191
>(lhs: Self, rhs: Other) -> Self {

0 commit comments

Comments
 (0)