Skip to content

Commit 857c19c

Browse files
committed
Comment about Clone on Context
1 parent fc785ea commit 857c19c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/cargo/core/resolver/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,24 @@ enum GraphNode {
295295
Link(PackageId, PackageId),
296296
}
297297

298+
// A `Context` is basically a bunch of local resolution information which is
299+
// kept around for all `BacktrackFrame` instances. As a result, this runs the
300+
// risk of being cloned *a lot* so we want to make this as cheap to clone as
301+
// possible.
298302
#[derive(Clone)]
299303
struct Context<'a> {
304+
// TODO: Both this and the map below are super expensive to clone. We should
305+
// switch to persistent hash maps if we can at some point or otherwise
306+
// make these much cheaper to clone in general.
300307
activations: Activations,
301-
resolve_graph: RcList<GraphNode>,
302308
resolve_features: HashMap<PackageId, HashSet<String>>,
309+
310+
// These are two cheaply-cloneable lists (O(1) clone) which are effectively
311+
// hash maps but are built up as "construction lists". We'll iterate these
312+
// at the very end and actually construct the map that we're making.
313+
resolve_graph: RcList<GraphNode>,
303314
resolve_replacements: RcList<(PackageId, PackageId)>,
315+
304316
replacements: &'a [(PackageIdSpec, Dependency)],
305317
}
306318

0 commit comments

Comments
 (0)