summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-04-01 09:10:04 -0400
committerGitHub <noreply@github.com>2024-04-01 09:10:04 -0400
commit240b362c002d17bc2b676673ed1b9406683ff0c2 (patch)
treed0c3cdc099b7cac4f29ae17f7ba03ee01a01c877 /cli
parent8d158058e5abab14d122712a716979b865620995 (diff)
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.
Diffstat (limited to 'cli')
-rw-r--r--cli/npm/byonm.rs3
-rw-r--r--cli/resolver.rs3
2 files changed, 4 insertions, 2 deletions
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<PackageJson> {
+ ) -> Option<Rc<PackageJson>> {
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<Option<PackageJson>, AnyError> {
+ ) -> Result<Option<Rc<PackageJson>>, AnyError> {
self
.node_resolver
.get_closest_package_json(referrer, permissions)