refactor(cli,core,ext,rt): remove some unnecessary clone or malloc (#17274)

This commit is contained in:
Yiyu Lin 2023-01-06 03:29:50 +08:00 committed by GitHub
parent 4e6b78cb43
commit 896dd56b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 86 additions and 72 deletions

View file

@ -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

View file

@ -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)
}