Skip to content

Commit df3a058

Browse files
committed
s/shortestEditScript/difference/g per proposal feedback
1 parent c0c068d commit df3a058

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

stdlib/public/core/Diffing.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ extension BidirectionalCollection {
127127
///
128128
/// - Complexity: O(*n* * *d*), where *n* is `other.count + self.count` and
129129
/// *d* is the number of changes between the two ordered collections.
130-
public func shortestEditScript<C>(
130+
public func difference<C>(
131131
from other: C, by areEquivalent: (Element, C.Element) -> Bool
132132
) -> OrderedCollectionDifference<Element>
133133
where C : BidirectionalCollection, C.Element == Self.Element
@@ -182,10 +182,10 @@ extension BidirectionalCollection where Element : Equatable {
182182
///
183183
/// - Complexity: O(*n* * *d*), where *n* is `other.count + self.count` and
184184
/// *d* is the number of changes between the two ordered collections.
185-
public func shortestEditScript<C>(from other: C) -> OrderedCollectionDifference<Element>
185+
public func difference<C>(from other: C) -> OrderedCollectionDifference<Element>
186186
where C: BidirectionalCollection, C.Element == Self.Element
187187
{
188-
return shortestEditScript(from: other, by: ==)
188+
return difference(from: other, by: ==)
189189
}
190190
}
191191

stdlib/public/core/OrderedCollectionDifference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public struct OrderedCollectionDifference<ChangeElement> {
9999
/// Creates an instance from a collection of changes.
100100
///
101101
/// For clients interested in the difference between two ordered
102-
/// collections, see `OrderedCollection.shortestEditScript(from:)`.
102+
/// collections, see `OrderedCollection.difference(from:)`.
103103
///
104104
/// To guarantee that instances are unambiguous and safe for compatible base
105105
/// states, this initializer will fail unless its parameter meets to the

test/stdlib/Diffing.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ let suite = "Diffing"
99
TestSuite(suite).test("Diffing empty collections") {
1010
let a = [Int]()
1111
let b = [Int]()
12-
let diff = b.shortestEditScript(from: a)
13-
expectEqual(diff, a.shortestEditScript(from: a))
12+
let diff = b.difference(from: a)
13+
expectEqual(diff, a.difference(from: a))
1414
expectTrue(diff.isEmpty)
1515
}
1616

@@ -335,7 +335,7 @@ TestSuite(suite).test("Basic diffing algorithm validators") {
335335
]
336336

337337
for (source, target, expected, line) in expectedChanges {
338-
let actual = target.shortestEditScript(from: source).inferringMoves()
338+
let actual = target.difference(from: source).inferringMoves()
339339
expectEqual(actual, OrderedCollectionDifference(expected), "failed test at line \(line)")
340340
}
341341
}
@@ -557,7 +557,7 @@ TestSuite(suite).test("Three way diff demo code") {
557557
let myLines = mine.components(separatedBy: "\n")
558558

559559
// Create a difference from base to theirs
560-
let diff = theirLines.shortestEditScript(from:baseLines)
560+
let diff = theirLines.difference(from: baseLines)
561561

562562
// Apply it to mine, if possible
563563
guard let patchedLines = myLines.applying(diff) else {
@@ -594,7 +594,7 @@ TestSuite(suite).test("Naive application by enumeration") {
594594
let theirLines = theirs.components(separatedBy: "\n")
595595

596596
// Create a difference from base to theirs
597-
let diff = theirLines.shortestEditScript(from:arr)
597+
let diff = theirLines.difference(from: arr)
598598

599599
for c in diff {
600600
switch c {
@@ -627,7 +627,7 @@ TestSuite(suite).test("Fast applicator boundary conditions") {
627627
if insertFirst { b.insert(12, at: 0) }
628628

629629
// Generate diff
630-
let diff = b.shortestEditScript(from: a)
630+
let diff = b.difference(from: a)
631631

632632
// Validate application
633633
expectEqual(b, a.applying(diff)!)
@@ -645,7 +645,7 @@ TestSuite(suite).test("Fast applicator fuzzer") {
645645
for _ in 0..<1000 {
646646
let a = makeArray()
647647
let b = makeArray()
648-
let d = b.shortestEditScript(from: a)
648+
let d = b.difference(from: a)
649649
let applied = a.applying(d)
650650
expectNotNil(applied)
651651
if let applied = applied {
@@ -655,7 +655,7 @@ TestSuite(suite).test("Fast applicator fuzzer") {
655655
// repro:
656656
let a = \(a)
657657
let b = \(b)
658-
let d = b.shortestEditScript(from: a)
658+
let d = b.difference(from: a)
659659
expectEqual(b, a.applying(d))
660660
""")
661661
break

0 commit comments

Comments
 (0)