mirror of https://github.com/astral-sh/uv
Use `FxHash` consistently (#632)
This commit is contained in:
parent
edd741bf13
commit
920e10fc8f
|
|
@ -2333,6 +2333,7 @@ dependencies = [
|
||||||
"pyproject-toml",
|
"pyproject-toml",
|
||||||
"requirements-txt",
|
"requirements-txt",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"rustc-hash",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ itertools = { workspace = true }
|
||||||
miette = { workspace = true, features = ["fancy"] }
|
miette = { workspace = true, features = ["fancy"] }
|
||||||
pubgrub = { workspace = true }
|
pubgrub = { workspace = true }
|
||||||
pyproject-toml = { workspace = true }
|
pyproject-toml = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
textwrap = { workspace = true }
|
textwrap = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
//! A standard interface for working with heterogeneous sources of requirements.
|
//! A standard interface for working with heterogeneous sources of requirements.
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
use pep508_rs::Requirement;
|
use pep508_rs::Requirement;
|
||||||
use puffin_normalize::{ExtraName, PackageName};
|
use puffin_normalize::{ExtraName, PackageName};
|
||||||
|
|
@ -65,7 +65,7 @@ pub(crate) struct RequirementsSpecification {
|
||||||
/// The constraints for the project.
|
/// The constraints for the project.
|
||||||
pub(crate) constraints: Vec<Requirement>,
|
pub(crate) constraints: Vec<Requirement>,
|
||||||
/// The extras used to collect requirements.
|
/// The extras used to collect requirements.
|
||||||
pub(crate) extras: HashSet<ExtraName>,
|
pub(crate) extras: FxHashSet<ExtraName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RequirementsSpecification {
|
impl RequirementsSpecification {
|
||||||
|
|
@ -82,7 +82,7 @@ impl RequirementsSpecification {
|
||||||
project: None,
|
project: None,
|
||||||
requirements: vec![requirement],
|
requirements: vec![requirement],
|
||||||
constraints: vec![],
|
constraints: vec![],
|
||||||
extras: HashSet::new(),
|
extras: FxHashSet::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RequirementsSource::RequirementsTxt(path) => {
|
RequirementsSource::RequirementsTxt(path) => {
|
||||||
|
|
@ -95,14 +95,14 @@ impl RequirementsSpecification {
|
||||||
.map(|entry| entry.requirement)
|
.map(|entry| entry.requirement)
|
||||||
.collect(),
|
.collect(),
|
||||||
constraints: requirements_txt.constraints.into_iter().collect(),
|
constraints: requirements_txt.constraints.into_iter().collect(),
|
||||||
extras: HashSet::new(),
|
extras: FxHashSet::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RequirementsSource::PyprojectToml(path) => {
|
RequirementsSource::PyprojectToml(path) => {
|
||||||
let contents = fs::read_to_string(path)?;
|
let contents = fs::read_to_string(path)?;
|
||||||
let pyproject_toml = toml::from_str::<pyproject_toml::PyProjectToml>(&contents)
|
let pyproject_toml = toml::from_str::<pyproject_toml::PyProjectToml>(&contents)
|
||||||
.with_context(|| format!("Failed to read `{}`", path.display()))?;
|
.with_context(|| format!("Failed to read `{}`", path.display()))?;
|
||||||
let mut used_extras = HashSet::new();
|
let mut used_extras = FxHashSet::default();
|
||||||
let mut requirements = Vec::new();
|
let mut requirements = Vec::new();
|
||||||
let mut project_name = None;
|
let mut project_name = None;
|
||||||
if let Some(project) = pyproject_toml.project {
|
if let Some(project) = pyproject_toml.project {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue