Skip to content

A couple of small improvements for the resilient builds of the stdlib #11545

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 2 commits into from
Aug 22, 2017
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
3 changes: 3 additions & 0 deletions stdlib/public/core/Comparable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ extension Comparable {
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
@_inlineable
public static func > (lhs: Self, rhs: Self) -> Bool {
return rhs < lhs
}
Expand All @@ -196,6 +197,7 @@ extension Comparable {
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
@_inlineable
public static func <= (lhs: Self, rhs: Self) -> Bool {
return !(rhs < lhs)
}
Expand All @@ -211,6 +213,7 @@ extension Comparable {
/// - rhs: Another value to compare.
/// - Returns: `true` if `lhs` is greater than or equal to `rhs`; otherwise,
/// `false`.
@_inlineable
public static func >= (lhs: Self, rhs: Self) -> Bool {
return !(lhs < rhs)
}
Expand Down
5 changes: 5 additions & 0 deletions stdlib/public/core/DoubleWidth.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ public struct DoubleWidth<Base : FixedWidthInteger> :
return (result, didCarry || hadPositiveOverflow)
}

// Specialize for the most popular types.
@_specialize(where Base == Int)
@_specialize(where Base == UInt)
@_specialize(where Base == Int64)
@_specialize(where Base == UInt64)
public func quotientAndRemainder(dividingBy other: DoubleWidth)
-> (quotient: DoubleWidth, remainder: DoubleWidth) {
let isNegative = (self < (0 as DoubleWidth)) != (other < (0 as DoubleWidth))
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/core/Integers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,7 @@ ${operatorComment(x.operator, False)}
// Heterogeneous non-masking shift in terms of shift-assignment
${operatorComment(x.nonMaskingOperator, False)}
@_semantics("optimize.sil.specialize.generic.partial.never")
@_inlineable
public static func ${x.nonMaskingOperator}<RHS: BinaryInteger>(
_ lhs: Self, _ rhs: RHS
) -> Self {
Expand Down Expand Up @@ -2184,6 +2185,7 @@ ${operatorComment(x.operator, False)}
// Heterogeneous masking shift
${operatorComment(x.operator, False)}
@_semantics("optimize.sil.specialize.generic.partial.never")
@_inlineable
public static func ${x.operator} <
Other : BinaryInteger
>(lhs: Self, rhs: Other) -> Self {
Expand Down