From 240b362c002d17bc2b676673ed1b9406683ff0c2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 1 Apr 2024 09:10:04 -0400 Subject: perf(node): put pkg json into an `Rc` (#23156) Was doing a bit of debugging on why some stuff is not working in a personal project and ran a quick debug profile and saw it cloning the pkg json a lot. We should put this in an Rc. --- cli/npm/byonm.rs | 3 ++- cli/resolver.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/npm/byonm.rs b/cli/npm/byonm.rs index d17be0e95..1e61ce885 100644 --- a/cli/npm/byonm.rs +++ b/cli/npm/byonm.rs @@ -3,6 +3,7 @@ use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; +use std::rc::Rc; use std::sync::Arc; use deno_ast::ModuleSpecifier; @@ -52,7 +53,7 @@ impl ByonmCliNpmResolver { &self, dep_name: &str, referrer: &ModuleSpecifier, - ) -> Option { + ) -> Option> { let referrer_path = referrer.to_file_path().ok()?; let mut current_folder = referrer_path.parent()?; loop { diff --git a/cli/resolver.rs b/cli/resolver.rs index 6594bf2d4..fc326e1b1 100644 --- a/cli/resolver.rs +++ b/cli/resolver.rs @@ -36,6 +36,7 @@ use std::collections::HashMap; use std::collections::HashSet; use std::path::Path; use std::path::PathBuf; +use std::rc::Rc; use std::sync::Arc; use crate::args::package_json::PackageJsonDeps; @@ -98,7 +99,7 @@ impl CliNodeResolver { &self, referrer: &ModuleSpecifier, permissions: &dyn NodePermissions, - ) -> Result, AnyError> { + ) -> Result>, AnyError> { self .node_resolver .get_closest_package_json(referrer, permissions) -- cgit v1.2.3