mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Remove InMemoryIndexRef
(#4544)
`InMemoryIndex` has recently been turned into an `Arc`, so we can now freely copy it instead using `Cow` tricks.
This commit is contained in:
parent
9701ead5be
commit
2ef34bd65b
1 changed files with 2 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
|||
use std::env;
|
||||
use std::io::stdout;
|
||||
use std::ops::Deref;
|
||||
use std::path::Path;
|
||||
|
||||
use anstream::{eprint, AutoStream, StripStream};
|
||||
|
@ -207,9 +206,9 @@ pub(crate) async fn pip_compile(
|
|||
// distributions will be built against the installed version, and so the index may contain
|
||||
// different package priorities than in the top-level resolution.
|
||||
let top_level_index = if python_version.is_some() {
|
||||
InMemoryIndexRef::Owned(InMemoryIndex::default())
|
||||
InMemoryIndex::default()
|
||||
} else {
|
||||
InMemoryIndexRef::Borrowed(&source_index)
|
||||
source_index.clone()
|
||||
};
|
||||
|
||||
// Determine the Python requirement, if the user requested a specific version.
|
||||
|
@ -597,20 +596,3 @@ impl OutputWriter {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// An owned or unowned [`InMemoryIndex`].
|
||||
enum InMemoryIndexRef<'a> {
|
||||
Owned(InMemoryIndex),
|
||||
Borrowed(&'a InMemoryIndex),
|
||||
}
|
||||
|
||||
impl Deref for InMemoryIndexRef<'_> {
|
||||
type Target = InMemoryIndex;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
Self::Owned(index) => index,
|
||||
Self::Borrowed(index) => index,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue