Skip to content

[stdlib] Improve readability by replacing if let with guard let in lexicographicallyPrecedes method #65384

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
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
22 changes: 10 additions & 12 deletions stdlib/public/core/SequenceAlgorithms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,18 @@ extension Sequence {
var iter1 = self.makeIterator()
var iter2 = other.makeIterator()
while true {
if let e1 = iter1.next() {
if let e2 = iter2.next() {
if try areInIncreasingOrder(e1, e2) {
return true
}
if try areInIncreasingOrder(e2, e1) {
return false
}
continue // Equivalent
}
guard let e1 = iter1.next() else {
return iter2.next() != nil
}
guard let e2 = iter2.next() else {
return false
}
if try areInIncreasingOrder(e1, e2) {
return true
}
if try areInIncreasingOrder(e2, e1) {
return false
}

return iter2.next() != nil
}
}
}
Expand Down