mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Make the resolver deterministic (#218)
At a minor performance cost... Closes https://github.com/astral-sh/puffin/issues/204.
This commit is contained in:
parent
bae3c89ab1
commit
1e4259a608
1 changed files with 4 additions and 8 deletions
|
@ -259,8 +259,6 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
|
|||
in_flight: &mut FxHashSet<String>,
|
||||
request_sink: &futures::channel::mpsc::UnboundedSender<Request>,
|
||||
) -> Result<(T, Option<PubGrubVersion>), ResolveError> {
|
||||
let mut selection = 0usize;
|
||||
|
||||
// Iterate over the potential packages, and fetch file metadata for any of them. These
|
||||
// represent our current best guesses for the versions that we _might_ select.
|
||||
for (index, (package, range)) in potential_packages.iter().enumerate() {
|
||||
|
@ -302,14 +300,12 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
selection = index;
|
||||
}
|
||||
|
||||
// TODO(charlie): This is really ugly, but we need to return `T`, not `&T` (and yet
|
||||
// we also need to iterate over `potential_packages` multiple times, so we can't
|
||||
// use `into_iter()`.)
|
||||
let (package, range) = potential_packages.swap_remove(selection);
|
||||
// Always choose the first package.
|
||||
// TODO(charlie): Devise a better strategy here (for example: always choose the package with
|
||||
// the fewest versions).
|
||||
let (package, range) = potential_packages.swap_remove(0);
|
||||
|
||||
return match package.borrow() {
|
||||
PubGrubPackage::Root => Ok((package, Some(MIN_VERSION.clone()))),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue