Skip to content

Commit

Permalink
Remove unused remotes field from graph
Browse files Browse the repository at this point in the history
  • Loading branch information
zebreus committed Jul 25, 2024
1 parent 389a1a2 commit 73b1f66
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
7 changes: 1 addition & 6 deletions src/graphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,17 @@ struct LockfileJsrGraphPackage {
}

/// Graph used to analyze a lockfile to determine which packages
/// and remotes can be removed based on config file changes.
/// can be removed based on config file changes.
pub struct LockfilePackageGraph {
root_packages: HashMap<LockfilePkgReq, LockfilePkgId>,
packages: HashMap<LockfilePkgId, LockfileGraphPackage>,
remotes: BTreeMap<String, String>,
}

impl LockfilePackageGraph {
pub fn from_lockfile<'a>(
npm: BTreeMap<String, NpmPackageInfo>,
jsr: BTreeMap<String, JsrPackageInfo>,
specifiers: BTreeMap<String, String>,
remotes: BTreeMap<String, String>,
old_config_file_packages: impl Iterator<Item = &'a str>,
) -> Self {
let mut root_packages =
Expand Down Expand Up @@ -167,7 +165,6 @@ impl LockfilePackageGraph {
Self {
root_packages,
packages,
remotes,
}
}

Expand Down Expand Up @@ -254,9 +251,7 @@ impl LockfilePackageGraph {
npm: &mut BTreeMap<String, NpmPackageInfo>,
jsr: &mut BTreeMap<String, JsrPackageInfo>,
specifiers: &mut BTreeMap<String, String>,
remotes: &mut BTreeMap<String, String>,
) {
*remotes = self.remotes;
for (req, id) in self.root_packages {
specifiers.insert(
req.0,
Expand Down
3 changes: 0 additions & 3 deletions src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,17 @@ impl Lockfile {
let npm = std::mem::take(&mut self.content.npm);
let jsr = std::mem::take(&mut self.content.jsr);
let specifiers = std::mem::take(&mut self.content.specifiers);
let remotes = std::mem::take(&mut self.content.remote);
let mut graph = LockfilePackageGraph::from_lockfile(
npm,
jsr,
specifiers,
remotes,
old_deps.iter().map(|dep| dep.as_str()),
);
graph.remove_root_packages(removed_deps.into_iter());
graph.populate_packages(
&mut self.content.npm,
&mut self.content.jsr,
&mut self.content.specifiers,
&mut self.content.remote,
);
}

Expand Down

0 comments on commit 73b1f66

Please sign in to comment.