mirror of
https://github.com/denoland/deno
synced 2024-08-27 12:00:17 +00:00
refactor(npm): avoid cloning snapshot for lockfile (#17451)
This commit is contained in:
parent
f0c79a676c
commit
40527526e5
|
@ -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(())
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue