Skip to content

Commit 599ab76

Browse files
committed
Remove ordered compare of optional and non-optional.
Safely unwrap two optionals used in the compare that follows. NFC, but this (or another work-around) will be required if either SE-0121 or SE-0123 is approved.
1 parent 932fe9d commit 599ab76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/SDK/Foundation/IndexSet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
349349
///
350350
/// - parameter range: The range of integers to include.
351351
public func indexRange(in range: Range<Element>) -> Range<Index> {
352-
if range.isEmpty {
352+
guard !range.isEmpty, let first = first, let last = last else {
353353
let i = _index(ofInteger: 0)
354354
return i..<i
355355
}
356-
356+
357357
if range.lowerBound > last || (range.upperBound - 1) < first {
358358
let i = _index(ofInteger: 0)
359359
return i..<i

0 commit comments

Comments
 (0)