mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Flatten ORs and ANDs in marker construction (#4260)
## Summary If we're ORing an OR, we should just append rather than nesting in another OR. In my branch, this let us simplify: ``` python_version < '3.10' or python_version > '3.12' or (python_version < '3.8' or python_version > '3.12') ``` To: ``` python_version < '3.10' or python_version > '3.12 ```
This commit is contained in:
parent
44041bccd2
commit
22795f85bc
1 changed files with 10 additions and 2 deletions
|
@ -1860,7 +1860,11 @@ impl MarkerTree {
|
|||
_ => {}
|
||||
}
|
||||
if let MarkerTree::And(ref mut exprs) = *self {
|
||||
exprs.push(tree);
|
||||
if let MarkerTree::And(tree) = tree {
|
||||
exprs.extend(tree);
|
||||
} else {
|
||||
exprs.push(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1878,7 +1882,11 @@ impl MarkerTree {
|
|||
_ => {}
|
||||
}
|
||||
if let MarkerTree::Or(ref mut exprs) = *self {
|
||||
exprs.push(tree);
|
||||
if let MarkerTree::Or(tree) = tree {
|
||||
exprs.extend(tree);
|
||||
} else {
|
||||
exprs.push(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue