-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
1,475 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::sync::Arc; | ||
|
||
use rustc_hash::FxHashMap; | ||
|
||
use uv_normalize::PackageName; | ||
use uv_pep508::MarkerTree; | ||
|
||
/// The superset of markers for which a package is known to be relevant. | ||
/// | ||
/// These markers may not represent the exact set of relevant environments, as they aren't adjusted | ||
/// when backtracking; instead, we only _add_ to this set over the course of the resolution. As | ||
/// such, the marker value represents a superset of the environments in which the package is known | ||
/// to be included, but it may include environments in which the package is ultimately excluded. | ||
#[derive(Debug, Default, Clone)] | ||
pub(crate) struct KnownMarkers(Arc<FxHashMap<PackageName, MarkerTree>>); | ||
|
||
impl KnownMarkers { | ||
/// Inserts the given [`MarkerTree`] for the given package name. | ||
pub(crate) fn insert(&mut self, package_name: PackageName, marker_tree: MarkerTree) { | ||
Arc::make_mut(&mut self.0) | ||
.entry(package_name) | ||
.or_insert(MarkerTree::FALSE) | ||
.or(marker_tree); | ||
} | ||
|
||
/// Returns the [`MarkerTree`] for the given package name, if it exists. | ||
pub(crate) fn get(&self, package_name: &PackageName) -> Option<&MarkerTree> { | ||
self.0.get(package_name) | ||
} | ||
} |
Oops, something went wrong.