Skip to content

Commit 9db06bb

Browse files
committed
Use array literals to provide IndexPaths for compatibility with Swift Package Manager
1 parent 30d9b35 commit 9db06bb

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

Sources/Differ/Diff+AppKit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ extension BatchUpdate {
99
deletions = diff.compactMap { element -> IndexPath? in
1010
switch element {
1111
case let .delete(at):
12-
return indexPathTransform(IndexPath(item: at, section: 0))
12+
return indexPathTransform([at, 0])
1313
default: return nil
1414
}
1515
}
1616
insertions = diff.compactMap { element -> IndexPath? in
1717
switch element {
1818
case let .insert(at):
19-
return indexPathTransform(IndexPath(item: at, section: 0))
19+
return indexPathTransform([at, 0])
2020
default: return nil
2121
}
2222
}
2323
moves = diff.compactMap { element -> MoveStep? in
2424
switch element {
2525
case let .move(from, to):
26-
return MoveStep(from: indexPathTransform(IndexPath(item: from, section: 0)), to: indexPathTransform(IndexPath(item: to, section: 0)))
26+
return MoveStep(from: indexPathTransform([from, 0]), to: indexPathTransform([to, 0]))
2727
default: return nil
2828
}
2929
}

Sources/Differ/Diff+UIKit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ extension BatchUpdate {
99
deletions = diff.compactMap { element -> IndexPath? in
1010
switch element {
1111
case let .delete(at):
12-
return indexPathTransform(IndexPath(row: at, section: 0))
12+
return indexPathTransform([at, 0])
1313
default: return nil
1414
}
1515
}
1616
insertions = diff.compactMap { element -> IndexPath? in
1717
switch element {
1818
case let .insert(at):
19-
return indexPathTransform(IndexPath(row: at, section: 0))
19+
return indexPathTransform([at, 0])
2020
default: return nil
2121
}
2222
}
2323
moves = diff.compactMap { element -> MoveStep? in
2424
switch element {
2525
case let .move(from, to):
26-
return MoveStep(from: indexPathTransform(IndexPath(row: from, section: 0)), to: indexPathTransform(IndexPath(row: to, section: 0)))
26+
return MoveStep(from: indexPathTransform([from, 0]), to: indexPathTransform([to, 0]))
2727
default: return nil
2828
}
2929
}

Sources/Differ/NestedBatchUpdate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ struct NestedBatchUpdate {
2727
diff.forEach { element in
2828
switch element {
2929
case let .deleteElement(at, section):
30-
itemDeletions.append(indexPathTransform(IndexPath(item: at, section: section)))
30+
itemDeletions.append(indexPathTransform([at, section]))
3131
case let .insertElement(at, section):
32-
itemInsertions.append(indexPathTransform(IndexPath(item: at, section: section)))
32+
itemInsertions.append(indexPathTransform([at, section]))
3333
case let .moveElement(from, to):
34-
itemMoves.append((indexPathTransform(IndexPath(item: from.item, section: from.section)), indexPathTransform(IndexPath(item: to.item, section: to.section))))
34+
itemMoves.append((indexPathTransform([from.item, from.section]), indexPathTransform([to.item, to.section])))
3535
case let .deleteSection(at):
3636
sectionDeletions.insert(sectionTransform(at))
3737
case let .insertSection(at):

Tests/DifferTests/BatchUpdateTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import XCTest
33

44
private func IP(_ row: Int, _ section: Int) -> IndexPath {
5-
return IndexPath(item: row, section: section)
5+
return [row, section]
66
}
77

88
class BatchUpdateTests: XCTestCase {

0 commit comments

Comments
 (0)