Skip to content

Commit 80f052e

Browse files
authored
[stdlib] Switch to a linear-space variant of Myers diffing (#83212)
This changes the implementation for `Collection.difference(from:)` to use a linear-space complexity variation of the same Myers algorithm. The new version is similar in execution time to the existing one, but should alleviate memory pressure when diffing collections where the number of differences approaches the size of the collection. While the new algorithm returns a set of changes that is the same size as the previous version, the specific changes are not guaranteed to be the same. rdar://155829876
1 parent 3e981b7 commit 80f052e

File tree

2 files changed

+389
-131
lines changed

2 files changed

+389
-131
lines changed

benchmark/single-source/Diffing.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public let benchmarks = [
5252
BenchmarkInfo(
5353
name: "Diffing.Large.Similar",
5454
runFunction: { diff($0, from: bigUnabridgedLorem, to: bigLoremIpsum) },
55-
tags: t,
55+
tags: t + [.skip],
5656
setUpFunction: { blackHole((bigUnabridgedLorem, bigLoremIpsum)) }),
5757
BenchmarkInfo(
5858
name: "Diffing.Large.Disparate",
5959
runFunction: { diff($0, from: bigNumbersAndSymbols, to: bigAlphabets) },
60-
tags: t,
60+
tags: t + [.skip],
6161
setUpFunction: { blackHole((bigNumbersAndSymbols, bigAlphabets)) }),
6262
]
6363

0 commit comments

Comments
 (0)