Skip to content

Commit 9b0ac25

Browse files
committed
Add Equatable Instances to Many Incremental Data Structures
The hashable bound on both key and value for many of the maps implies a derivable Equatable instance that we can pick up.
1 parent 860e677 commit 9b0ac25

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

Sources/SwiftDriver/IncrementalCompilation/BidirectionalMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// Like a two-way dictionary, only works for accessing present members
14-
public struct BidirectionalMap<T1: Hashable, T2: Hashable> {
14+
public struct BidirectionalMap<T1: Hashable, T2: Hashable>: Equatable {
1515
private var map1: [T1: T2] = [:]
1616
private var map2: [T2: T1] = [:]
1717

Sources/SwiftDriver/IncrementalCompilation/DictionaryOfDictionaries.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,7 @@ extension DictionaryOfDictionaries {
135135
return old
136136
}
137137
}
138+
139+
// MARK: - identity
140+
141+
extension DictionaryOfDictionaries: Equatable where Value: Equatable {}

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ extension ModuleDependencyGraph.Integrator {
193193
_ sourceFileUseNode: SourceFileDependencyGraph.Node,
194194
_ moduleUseNode: Graph.Node
195195
) {
196-
source.forEachDefDependedUpon(by: sourceFileUseNode) {
197-
def in
196+
source.forEachDefDependedUpon(by: sourceFileUseNode) { def in
198197
let isNewUse = destination.nodeFinder.record(def: def.key,
199198
use: moduleUseNode)
200199
if let externalDependency = def.key.designator.externalDependency,

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Node.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extension ModuleDependencyGraph {
6868
}
6969
// MARK: - comparing, hashing
7070
extension ModuleDependencyGraph.Node: Equatable, Hashable {
71-
public static func == (lhs: Graph.Node, rhs: Graph.Node ) -> Bool {
71+
public static func == (lhs: Graph.Node, rhs: Graph.Node) -> Bool {
7272
lhs.dependencyKey == rhs.dependencyKey && lhs.fingerprint == rhs.fingerprint
7373
&& lhs.swiftDeps == rhs.swiftDeps
7474
}

Sources/SwiftDriver/IncrementalCompilation/Multidictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// Like a Dictionary, but can have >1 value per key (i.e., a multimap)
14-
struct Multidictionary<Key: Hashable, Value: Hashable>: Collection {
14+
struct Multidictionary<Key: Hashable, Value: Hashable>: Collection, Equatable {
1515
public typealias OuterDict = [Key: Set<Value>]
1616
public typealias InnerSet = Set<Value>
1717
private var outerDict = OuterDict()

Sources/SwiftDriver/IncrementalCompilation/TwoDMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
/// A map with 2 keys that can iterate in a number of ways
15-
public struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection {
15+
public struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection, Equatable {
1616

1717
private var map1 = DictionaryOfDictionaries<Key1, Key2, Value>()
1818
private var map2 = DictionaryOfDictionaries<Key2, Key1, Value>()

0 commit comments

Comments
 (0)