diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-11-11 09:01:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-11 17:01:48 +0000 |
commit | 9f4a45561f4a01019cdbff86e2056de0296e791b (patch) | |
tree | a9c2c4b1664d6f4640115345882ae068c1a5a216 /cli/npm/managed/mod.rs | |
parent | 56e76242f3d7082e412bc698ebc737d24910cb60 (diff) |
perf: snapshot runtime ops (#21127)
Closes https://github.com/denoland/deno/issues/21135
~1ms startup time improvement
---------
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'cli/npm/managed/mod.rs')
-rw-r--r-- | cli/npm/managed/mod.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index d59b81912..6cf7e6a32 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -492,6 +492,23 @@ impl ManagedCliNpmResolver { } impl NpmResolver for ManagedCliNpmResolver { + /// Gets the state of npm for the process. + fn get_npm_process_state(&self) -> String { + serde_json::to_string(&NpmProcessState { + kind: NpmProcessStateKind::Snapshot( + self + .resolution + .serialized_valid_snapshot() + .into_serialized(), + ), + local_node_modules_path: self + .fs_resolver + .node_modules_path() + .map(|p| p.to_string_lossy().to_string()), + }) + .unwrap() + } + fn resolve_package_folder_from_package( &self, name: &str, @@ -571,23 +588,6 @@ impl CliNpmResolver for ManagedCliNpmResolver { self.resolve_pkg_folder_from_pkg_id(&pkg_id) } - /// Gets the state of npm for the process. - fn get_npm_process_state(&self) -> String { - serde_json::to_string(&NpmProcessState { - kind: NpmProcessStateKind::Snapshot( - self - .resolution - .serialized_valid_snapshot() - .into_serialized(), - ), - local_node_modules_path: self - .fs_resolver - .node_modules_path() - .map(|p| p.to_string_lossy().to_string()), - }) - .unwrap() - } - fn check_state_hash(&self) -> Option<u64> { // We could go further and check all the individual // npm packages, but that's probably overkill. |