diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-08 19:45:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 19:45:04 -0500 |
commit | 8b0a612e308d593205690729e23dafe0bce02eb9 (patch) | |
tree | b4e29cef4e8802511a0911c7ed3448f2672c2706 /cli/cache/mod.rs | |
parent | ef9b66950f4557003bc7d4246da838545466a518 (diff) |
perf: disable fetching graph cache info except for `deno info` (#17698)
Diffstat (limited to 'cli/cache/mod.rs')
-rw-r--r-- | cli/cache/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index c8fcaa223..9b6d14a5c 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -45,6 +45,7 @@ pub struct FetchCacher { dynamic_permissions: PermissionsContainer, file_fetcher: Arc<FileFetcher>, root_permissions: PermissionsContainer, + cache_info_enabled: bool, } impl FetchCacher { @@ -59,12 +60,23 @@ impl FetchCacher { dynamic_permissions, file_fetcher, root_permissions, + cache_info_enabled: false, } } + + /// The cache information takes a bit of time to fetch and it's + /// not always necessary. It should only be enabled for deno info. + pub fn enable_loading_cache_info(&mut self) { + self.cache_info_enabled = true; + } } impl Loader for FetchCacher { fn get_cache_info(&self, specifier: &ModuleSpecifier) -> Option<CacheInfo> { + if !self.cache_info_enabled { + return None; + } + if matches!(specifier.scheme(), "npm" | "node") { return None; } |