Skip to content

Commit b0224bf

Browse files
authored
perf: avoid double call to parse_package_specifier (#465)
1 parent 0068844 commit b0224bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl<C: Cache> ResolverGeneric<C> {
496496
specifier: &str,
497497
ctx: &mut Ctx,
498498
) -> Result<C::Cp, ResolveError> {
499-
let (_, subpath) = Self::parse_package_specifier(specifier);
499+
let (package_name, subpath) = Self::parse_package_specifier(specifier);
500500
if subpath.is_empty() {
501501
ctx.with_fully_specified(false);
502502
}
@@ -505,7 +505,9 @@ impl<C: Cache> ResolverGeneric<C> {
505505
return Ok(path);
506506
}
507507
// 6. LOAD_NODE_MODULES(X, dirname(Y))
508-
if let Some(path) = self.load_node_modules(cached_path, specifier, ctx)? {
508+
if let Some(path) =
509+
self.load_node_modules(cached_path, specifier, package_name, subpath, ctx)?
510+
{
509511
return Ok(path);
510512
}
511513
// 7. THROW "not found"
@@ -723,6 +725,8 @@ impl<C: Cache> ResolverGeneric<C> {
723725
&self,
724726
cached_path: &C::Cp,
725727
specifier: &str,
728+
package_name: &str,
729+
subpath: &str,
726730
ctx: &mut Ctx,
727731
) -> ResolveResult<C::Cp> {
728732
#[cfg(feature = "yarn_pnp")]
@@ -732,7 +736,6 @@ impl<C: Cache> ResolverGeneric<C> {
732736
}
733737
}
734738

735-
let (package_name, subpath) = Self::parse_package_specifier(specifier);
736739
// 1. let DIRS = NODE_MODULES_PATHS(START)
737740
// 2. for each DIR in DIRS:
738741
for module_name in &self.options.modules {

0 commit comments

Comments
 (0)