From 085fde8955f927d172f73fe65a9903d0324b14d0 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 21 Nov 2024 08:56:00 -0500 Subject: [PATCH] uv-resolver: simplify `fork_markers` construction This doesn't change any behavior. My guess is that this code was a casualty of refactoring. But basically, it was doing redundant case analysis and iterating over all resolutions (even though it's in the branch that can only occur when there is only one resolution). --- crates/uv-resolver/src/resolution/output.rs | 27 +++------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/crates/uv-resolver/src/resolution/output.rs b/crates/uv-resolver/src/resolution/output.rs index 1f7b33746..93ac6ddee 100644 --- a/crates/uv-resolver/src/resolution/output.rs +++ b/crates/uv-resolver/src/resolution/output.rs @@ -174,33 +174,12 @@ impl ResolverOutput { // Extract the `Requires-Python` range, if provided. let requires_python = python.target().clone(); - let fork_markers = if let [resolution] = resolutions { - resolution - .env - .try_markers() - .map(|_| { - resolutions - .iter() - .map(|resolution| { - resolution - .env - .try_markers() - .expect("A non-forking resolution exists in forking mode") - .clone() - }) - .collect() - }) - .unwrap_or_else(Vec::new) + let fork_markers: Vec = if let [resolution] = resolutions { + resolution.env.try_markers().cloned().into_iter().collect() } else { resolutions .iter() - .map(|resolution| { - resolution - .env - .try_markers() - .cloned() - .unwrap_or(MarkerTree::TRUE) - }) + .map(|resolution| resolution.env.try_markers().cloned().unwrap_or_default()) .collect() };