Skip to content

Remove compilation bottleneck for Swift 5.3.2 builds #147

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
Jun 21, 2021
Merged
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
12 changes: 9 additions & 3 deletions Sources/Algorithms/Stride.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down