Compare commits

..
Author SHA1 Message Date
Matt Zanchelli b275ccd212 Remove extraneous space in inline documentation 2021-08-04 10:20:31 -07:00
Iain Smith 50be2c8b3f Remove compilation bottleneck for Swift 5.3.2 builds (#147)
Benchmarks on Xcode 12.4 showed compiling / type checking
StrideCollection.offsetBackward was the bottleneck for building
the package. Replacing the ternary operator in that function
with an explicit if/else removes the bottleneck.
2021-06-21 11:17:42 -05:00
2 changed files with 10 additions and 4 deletions

No files matched your search

+1 -1
View File
@@ -159,7 +159,7 @@ extension Collection {
/// element and iterates over every non-nil element from the original
/// `Collection`.
///
/// Complexity: O(*n*) where *n* is the number of elements in the
/// Complexity: O(*n*) where *n* is the number of elements in the
/// original `Collection`.
@inlinable
public func compacted<Unwrapped>() -> CompactedCollection<Self, Unwrapped>
+9 -3
View File
@@ -226,9 +226,15 @@ extension StrideCollection: Collection {
offsetBy n: Int,
limitedBy limit: Index
) -> Index? {
let distance = i == endIndex
? -((base.count - 1) % stride + 1) + (n - 1) * -stride
: n * -stride
// We typically use the ternary operator but this significantly increases
// compile times when using Swift 5.3.2
// https://github.com/apple/swift-algorithms/issues/146
let distance: Int
if i == endIndex {
distance = -((base.count - 1) % stride + 1) + (n - 1) * -stride
} else {
distance = n * -stride
}
return base.index(
i.base,
offsetBy: distance,