Skip to content

Commit 2511bde

Browse files
committed
Uses swift instead of if
1 parent c0413c2 commit 2511bde

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/Foundation/IndexPath.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,14 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
634634

635635
fileprivate init(nsIndexPath: ReferenceType) {
636636
let count = nsIndexPath.length
637-
if count == 0 {
637+
switch count {
638+
case 0:
638639
_indexes = []
639-
} else if count == 1 {
640+
case 1:
640641
_indexes = .single(nsIndexPath.index(atPosition: 0))
641-
} else if count == 2 {
642+
case 2:
642643
_indexes = .pair(nsIndexPath.index(atPosition: 0), nsIndexPath.index(atPosition: 1))
643-
} else {
644+
default:
644645
let indexes = Array<Int>(unsafeUninitializedCapacity: count) { buf, initializedCount in
645646
nsIndexPath.getIndexes(buf.baseAddress!, range: NSRange(location: 0, length: count))
646647
initializedCount = count

0 commit comments

Comments
 (0)