1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

refactor(npm): avoid cloning snapshot for lockfile (#17451)

This commit is contained in:
David Sherret 2023-01-16 14:46:30 -05:00 committed by GitHub
parent f0c79a676c
commit 40527526e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 13 deletions

View file

@ -382,10 +382,6 @@ impl NpmResolution {
.cloned()
}
pub fn all_packages(&self) -> Vec<NpmResolutionPackage> {
self.snapshot.read().all_packages()
}
pub fn all_packages_partitioned(&self) -> NpmPackagesPartitioned {
self.snapshot.read().all_packages_partitioned()
}
@ -398,15 +394,12 @@ impl NpmResolution {
self.snapshot.read().clone()
}
pub fn lock(
&self,
lockfile: &mut Lockfile,
snapshot: &NpmResolutionSnapshot,
) -> Result<(), AnyError> {
pub fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
let snapshot = self.snapshot.read();
for (package_req, package_id) in snapshot.package_reqs.iter() {
lockfile.insert_npm_specifier(package_req, package_id);
}
for package in self.all_packages() {
for package in snapshot.all_packages() {
lockfile.check_or_insert_npm_package(&package)?;
}
Ok(())

View file

@ -169,8 +169,7 @@ impl InnerNpmPackageResolver for GlobalNpmPackageResolver {
}
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
let snapshot = self.resolution.snapshot();
self.resolution.lock(lockfile, &snapshot)
self.resolution.lock(lockfile)
}
}

View file

@ -263,7 +263,7 @@ impl InnerNpmPackageResolver for LocalNpmPackageResolver {
}
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
self.resolution.lock(lockfile, &self.snapshot())
self.resolution.lock(lockfile)
}
}