mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
refactor(cli,core,ext,rt): remove some unnecessary clone
or malloc
(#17274)
This commit is contained in:
parent
4e6b78cb43
commit
896dd56b7a
24 changed files with 86 additions and 72 deletions
|
@ -210,7 +210,7 @@ impl NpmResolutionPackage {
|
|||
pub struct NpmResolution {
|
||||
api: RealNpmRegistryApi,
|
||||
snapshot: RwLock<NpmResolutionSnapshot>,
|
||||
update_sempahore: tokio::sync::Semaphore,
|
||||
update_semaphore: tokio::sync::Semaphore,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for NpmResolution {
|
||||
|
@ -230,7 +230,7 @@ impl NpmResolution {
|
|||
Self {
|
||||
api,
|
||||
snapshot: RwLock::new(initial_snapshot.unwrap_or_default()),
|
||||
update_sempahore: tokio::sync::Semaphore::new(1),
|
||||
update_semaphore: tokio::sync::Semaphore::new(1),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ impl NpmResolution {
|
|||
package_reqs: Vec<NpmPackageReq>,
|
||||
) -> Result<(), AnyError> {
|
||||
// only allow one thread in here at a time
|
||||
let _permit = self.update_sempahore.acquire().await.unwrap();
|
||||
let _permit = self.update_semaphore.acquire().await.unwrap();
|
||||
let snapshot = self.snapshot.read().clone();
|
||||
|
||||
let snapshot = self
|
||||
|
@ -255,7 +255,7 @@ impl NpmResolution {
|
|||
package_reqs: HashSet<NpmPackageReq>,
|
||||
) -> Result<(), AnyError> {
|
||||
// only allow one thread in here at a time
|
||||
let _permit = self.update_sempahore.acquire().await.unwrap();
|
||||
let _permit = self.update_semaphore.acquire().await.unwrap();
|
||||
let snapshot = self.snapshot.read().clone();
|
||||
|
||||
let has_removed_package = !snapshot
|
||||
|
|
|
@ -132,7 +132,7 @@ impl std::fmt::Display for NpmPackageReq {
|
|||
|
||||
impl NpmPackageReq {
|
||||
pub fn from_str(text: &str) -> Result<Self, AnyError> {
|
||||
// probably should do something more targetted in the future
|
||||
// probably should do something more targeted in the future
|
||||
let reference = NpmPackageReference::from_str(&format!("npm:{}", text))?;
|
||||
Ok(reference.req)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue