mirror of https://github.com/astral-sh/uv
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).
This commit is contained in:
parent
2b6d9b2289
commit
085fde8955
|
|
@ -174,33 +174,12 @@ impl ResolverOutput {
|
||||||
// Extract the `Requires-Python` range, if provided.
|
// Extract the `Requires-Python` range, if provided.
|
||||||
let requires_python = python.target().clone();
|
let requires_python = python.target().clone();
|
||||||
|
|
||||||
let fork_markers = if let [resolution] = resolutions {
|
let fork_markers: Vec<MarkerTree> = if let [resolution] = resolutions {
|
||||||
resolution
|
resolution.env.try_markers().cloned().into_iter().collect()
|
||||||
.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)
|
|
||||||
} else {
|
} else {
|
||||||
resolutions
|
resolutions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|resolution| {
|
.map(|resolution| resolution.env.try_markers().cloned().unwrap_or_default())
|
||||||
resolution
|
|
||||||
.env
|
|
||||||
.try_markers()
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or(MarkerTree::TRUE)
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue