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:
parent
f0c79a676c
commit
40527526e5
3 changed files with 5 additions and 13 deletions
|
@ -382,10 +382,6 @@ impl NpmResolution {
|
||||||
.cloned()
|
.cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_packages(&self) -> Vec<NpmResolutionPackage> {
|
|
||||||
self.snapshot.read().all_packages()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn all_packages_partitioned(&self) -> NpmPackagesPartitioned {
|
pub fn all_packages_partitioned(&self) -> NpmPackagesPartitioned {
|
||||||
self.snapshot.read().all_packages_partitioned()
|
self.snapshot.read().all_packages_partitioned()
|
||||||
}
|
}
|
||||||
|
@ -398,15 +394,12 @@ impl NpmResolution {
|
||||||
self.snapshot.read().clone()
|
self.snapshot.read().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lock(
|
pub fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
|
||||||
&self,
|
let snapshot = self.snapshot.read();
|
||||||
lockfile: &mut Lockfile,
|
|
||||||
snapshot: &NpmResolutionSnapshot,
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
for (package_req, package_id) in snapshot.package_reqs.iter() {
|
for (package_req, package_id) in snapshot.package_reqs.iter() {
|
||||||
lockfile.insert_npm_specifier(package_req, package_id);
|
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)?;
|
lockfile.check_or_insert_npm_package(&package)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -169,8 +169,7 @@ impl InnerNpmPackageResolver for GlobalNpmPackageResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
|
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
|
||||||
let snapshot = self.resolution.snapshot();
|
self.resolution.lock(lockfile)
|
||||||
self.resolution.lock(lockfile, &snapshot)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl InnerNpmPackageResolver for LocalNpmPackageResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
|
fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> {
|
||||||
self.resolution.lock(lockfile, &self.snapshot())
|
self.resolution.lock(lockfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue