@@ -40,6 +40,23 @@ impl ConflictStore {
40
40
}
41
41
}
42
42
}
43
+
44
+ pub fn insert < ' a > (
45
+ & mut self ,
46
+ mut iter : impl Iterator < Item = & ' a PackageId > ,
47
+ con : BTreeMap < PackageId , ConflictReason > ,
48
+ ) {
49
+ if let Some ( pid) = iter. next ( ) {
50
+ if let ConflictStore :: Map ( p) = self {
51
+ p. entry ( pid. clone ( ) )
52
+ . or_insert_with ( || ConflictStore :: Map ( HashMap :: new ( ) ) )
53
+ . insert ( iter, con) ;
54
+ }
55
+ // else, We already have a subset of this in the ConflictStore
56
+ } else {
57
+ * self = ConflictStore :: Con ( con)
58
+ }
59
+ }
43
60
}
44
61
45
62
pub ( super ) struct ConflictCache {
@@ -113,30 +130,11 @@ impl ConflictCache {
113
130
/// `dep` is known to be unresolvable if
114
131
/// all the `PackageId` entries are activated
115
132
pub fn insert ( & mut self , dep : & Dependency , con : & BTreeMap < PackageId , ConflictReason > ) {
116
- let mut past = self
117
- . con_from_dep
133
+ self . con_from_dep
118
134
. entry ( dep. clone ( ) )
119
- . or_insert_with ( || ConflictStore :: Map ( HashMap :: new ( ) ) ) ;
120
-
121
- for pid in con. keys ( ) {
122
- match past {
123
- ConflictStore :: Con ( _) => {
124
- // We already have a subset of this in the ConflictStore
125
- return ;
126
- }
127
- ConflictStore :: Map ( p) => {
128
- past = p
129
- . entry ( pid. clone ( ) )
130
- . or_insert_with ( || ConflictStore :: Map ( HashMap :: new ( ) ) ) ;
131
- }
132
- }
133
- }
135
+ . or_insert_with ( || ConflictStore :: Map ( HashMap :: new ( ) ) )
136
+ . insert ( con. keys ( ) , con. clone ( ) ) ;
134
137
135
- if let ConflictStore :: Con ( _) = past {
136
- // We already have this in the ConflictStore
137
- return ;
138
- }
139
- * past = ConflictStore :: Con ( con. clone ( ) ) ;
140
138
trace ! (
141
139
"{} = \" {}\" adding a skip {:?}" ,
142
140
dep. package_name( ) ,
0 commit comments