summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-11-11 11:33:57 -0500
committerGitHub <noreply@github.com>2022-11-11 11:33:57 -0500
commit8dc242f7891492886827a350b7736c11df7aa419 (patch)
treef9d9ceca4361c71ba08b0e304d2e4a1696ed9140 /cli/main.rs
parent7f0546a6b736430e6c39c55cfa77f39e70ffc9a2 (diff)
perf: more efficient `deno cache` and npm package info usage (#16592)
1. There was a lot of cloning going on with `NpmPackageInfo`. This is now stored in an `Arc<NpmPackageInfo>` and cloning only happens on the individual version. 2. The package cache is now cleared from memory after resolution. 3. This surfaced a bug in `deno cache` and I noticed it can be more efficient if we have multiple root specifiers if we provide all the specifiers as roots.
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/cli/main.rs b/cli/main.rs
index cf1bb4ca5..31ac4b331 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -284,23 +284,23 @@ async fn check_command(
async fn load_and_type_check(
ps: &ProcState,
- files: &Vec<String>,
+ files: &[String],
) -> Result<(), AnyError> {
let lib = ps.options.ts_type_lib_window();
- for file in files {
- let specifier = resolve_url_or_path(file)?;
-
- ps.prepare_module_load(
- vec![specifier],
- false,
- lib,
- Permissions::allow_all(),
- Permissions::allow_all(),
- false,
- )
- .await?;
- }
+ let specifiers = files
+ .iter()
+ .map(|file| resolve_url_or_path(file))
+ .collect::<Result<Vec<_>, _>>()?;
+ ps.prepare_module_load(
+ specifiers,
+ false,
+ lib,
+ Permissions::allow_all(),
+ Permissions::allow_all(),
+ false,
+ )
+ .await?;
Ok(())
}