Skip to content

Commit

Permalink
Remove unnecessary “from” parameter from Diff.patch(…)
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
tonyarnold committed Sep 26, 2018
1 parent 0d07963 commit 1e38ecc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/Differ/ExtendedPatch.swift
Expand Up @@ -129,7 +129,7 @@ extension ExtendedDiff {
}

func generateSortedPatchElements<T: Collection>(from: T, to: T) -> [SortedPatchElement<T.Element>] {
let patch = source.patch(from: from, to: to)
let patch = source.patch(to: to)
return patch.indices.map {
SortedPatchElement(
value: patch[$0],
Expand Down
2 changes: 1 addition & 1 deletion Sources/Differ/Patch+Sort.swift
Expand Up @@ -33,7 +33,7 @@ public extension Diff {
to: T,
sort: OrderedBefore
) -> [Patch<T.Element>] {
let shiftedPatch = patch(from: from, to: to)
let shiftedPatch = patch(to: to)
return shiftedPatchElements(from: sortedPatchElements(
from: shiftedPatch,
sortBy: sort
Expand Down
8 changes: 2 additions & 6 deletions Sources/Differ/Patch.swift
Expand Up @@ -22,13 +22,9 @@ public extension Diff {
/// - Complexity: O(N)
///
/// - Parameters:
/// - from: The source collection (usually the source collecetion of the callee)
/// - to: The target collection (usually the target collecetion of the callee)
/// - Returns: A sequence of steps to obtain `to` collection from the `from` one.
public func patch<T: Collection>(
from: T,
to: T
) -> [Patch<T.Element>] {
public func patch<T: Collection>(to: T) -> [Patch<T.Element>] {
var shift = 0
return map { element in
switch element {
Expand All @@ -55,7 +51,7 @@ public func patch<T: Collection>(
from: T,
to: T
) -> [Patch<T.Element>] where T.Element: Equatable {
return from.diff(to).patch(from: from, to: to)
return from.diff(to).patch(to: to)
}

extension Patch: CustomDebugStringConvertible {
Expand Down

0 comments on commit 1e38ecc

Please sign in to comment.