Skip to content

Commit a1e51a1

Browse files
committed
[stdlib] Admit defeat & replace @_transparent with @inline(__always)
1 parent 487baca commit a1e51a1

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

stdlib/public/core/ClosedRange.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ extension ClosedRange: RangeExpression {
128128
/// - Parameter element: The element to check for containment.
129129
/// - Returns: `true` if `element` is contained in the range; otherwise,
130130
/// `false`.
131-
@_transparent
131+
@inlinable
132+
@inline(__always)
132133
public func contains(_ element: Bound) -> Bool {
133134
return element >= self.lowerBound && element <= self.upperBound
134135
}
@@ -383,7 +384,7 @@ extension ClosedRange {
383384
///
384385
/// - Complexity: O(1)
385386
@_alwaysEmitIntoClient
386-
@_transparent
387+
@inline(__always)
387388
public func contains(_ other: ClosedRange<Bound>) -> Bool {
388389
lowerBound <= other.lowerBound && upperBound >= other.upperBound
389390
}

stdlib/public/core/Range.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ public struct Range<Bound: Comparable> {
195195
/// - Parameter element: The element to check for containment.
196196
/// - Returns: `true` if `element` is contained in the range; otherwise,
197197
/// `false`.
198-
@_transparent
198+
@inlinable
199+
@inline(__always)
199200
public func contains(_ element: Bound) -> Bool {
200201
return lowerBound <= element && element < upperBound
201202
}
@@ -683,7 +684,8 @@ extension PartialRangeFrom: RangeExpression {
683684
) -> Range<Bound> where C.Index == Bound {
684685
return self.lowerBound..<collection.endIndex
685686
}
686-
@_transparent
687+
@inlinable
688+
@inline(__always)
687689
public func contains(_ element: Bound) -> Bool {
688690
return lowerBound <= element
689691
}
@@ -1075,12 +1077,12 @@ extension Range {
10751077
///
10761078
/// - Complexity: O(1)
10771079
@_alwaysEmitIntoClient
1078-
@_transparent
1080+
@inline(__always)
10791081
public func contains(_ other: Range<Bound>) -> Bool {
10801082
other.isEmpty ||
10811083
(lowerBound <= other.lowerBound && upperBound >= other.upperBound)
10821084
}
1083-
1085+
10841086
/// Returns a Boolean value indicating whether the given closed range is
10851087
/// contained within this range.
10861088
///
@@ -1103,7 +1105,7 @@ extension Range {
11031105
///
11041106
/// - Complexity: O(1)
11051107
@_alwaysEmitIntoClient
1106-
@_transparent
1108+
@inline(__always)
11071109
public func contains(_ other: ClosedRange<Bound>) -> Bool {
11081110
lowerBound <= other.lowerBound && upperBound > other.upperBound
11091111
}

test/stdlib/RangeContainsInlining.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
// The sample functions below use bounds of different integer types to avoid
1111
// them tail-calling each other.
1212

13-
// CHECK-LABEL: define {{.*}} i1 @"$s21RangeContainsInlining08halfOpenB0ySbSnys4Int8VG_ADtF"
14-
// CHECK-NOT: call swiftcc
15-
// CHECK: icmp
16-
// CHECK-NOT: call swiftcc
17-
// CHECK-LABEL: {{^}}}
13+
// CHECK-OPTIMIZED-LABEL: define {{.*}} i1 @"$s21RangeContainsInlining08halfOpenB0ySbSnys4Int8VG_ADtF"
14+
// CHECK-OPTIMIZED-NOT: call swiftcc
15+
// CHECK-OPTIMIZED: icmp
16+
// CHECK-OPTIMIZED-NOT: call swiftcc
17+
// CHECK-OPTIMIZED-LABEL: {{^}}}
1818
public func halfOpenContains(_ r: Range<Int8>, _ i: Int8) -> Bool {
1919
r.contains(i)
2020
}
2121

2222
// CHECK-LABEL: define {{.*}} i1 @"$s21RangeContainsInlining06closedB0ySbSNys5Int16VG_ADtF"
23-
// CHECK-NOT: call swiftcc
24-
// CHECK: icmp
25-
// CHECK-NOT: call swiftcc
26-
// CHECK-LABEL: {{^}}}
23+
// CHECK-OPTIMIZED-NOT: call swiftcc
24+
// CHECK-OPTIMIZED: icmp
25+
// CHECK-OPTIMIZED-NOT: call swiftcc
26+
// CHECK-OPTIMIZED-LABEL: {{^}}}
2727
public func closedContains(_ r: ClosedRange<Int16>, _ i: Int16) -> Bool {
2828
r.contains(i)
2929
}

0 commit comments

Comments
 (0)