From 68adadf806ffca48d1542a89766d642ef38aee9f Mon Sep 17 00:00:00 2001 From: konsti Date: Wed, 8 Jan 2025 12:42:25 +0100 Subject: [PATCH] Improve file pinning comments (#10387) --- crates/uv-resolver/src/pins.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/uv-resolver/src/pins.rs b/crates/uv-resolver/src/pins.rs index b7e96f9b8..6d0d88f65 100644 --- a/crates/uv-resolver/src/pins.rs +++ b/crates/uv-resolver/src/pins.rs @@ -12,11 +12,14 @@ use crate::candidate_selector::Candidate; #[derive(Clone, Debug, Default)] pub(crate) struct FilePins(FxHashMap<(PackageName, uv_pep440::Version), ResolvedDist>); +// Inserts are common (every time we select a version) while reads are rare (converting the +// final resolution). impl FilePins { /// Pin a candidate package. pub(crate) fn insert(&mut self, candidate: &Candidate, dist: &CompatibleDist) { self.0 .entry((candidate.name().clone(), candidate.version().clone())) + // Avoid the expensive clone when a version is selected again. .or_insert_with(|| dist.for_installation().to_owned()); } @@ -26,7 +29,6 @@ impl FilePins { name: &PackageName, version: &uv_pep440::Version, ) -> Option<&ResolvedDist> { - // Inserts are common while reads are rare, so the clone here is overall faster. self.0.get(&(name.clone(), version.clone())) } }