mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
perf(node_resolver): reduce url to/from path conversions (#27839)
Extracted out of https://github.com/denoland/deno/pull/27838/files Reduces some allocations by accepting either a pathbuf or url for the referrer for resolution and returning either a pathbuf or url at the end, which the caller can then convert into to their preferred state. This is about 4% faster when still converting the final result to a url and 6% faster when keeping the result as a path in a benchmark I ran.
This commit is contained in:
parent
92dce12af7
commit
679902a108
28 changed files with 679 additions and 417 deletions
|
@ -667,7 +667,12 @@ impl<TGraphContainer: ModuleGraphContainer>
|
|||
ResolutionMode::Import,
|
||||
NodeResolutionKind::Execution,
|
||||
)
|
||||
.map_err(|e| JsErrorBox::from_err(e).into());
|
||||
.map_err(|e| JsErrorBox::from_err(e).into())
|
||||
.and_then(|url_or_path| {
|
||||
url_or_path
|
||||
.into_url()
|
||||
.map_err(|e| JsErrorBox::from_err(e).into())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,6 +701,8 @@ impl<TGraphContainer: ModuleGraphContainer>
|
|||
source,
|
||||
})
|
||||
})?
|
||||
.into_url()
|
||||
.map_err(JsErrorBox::from_err)?
|
||||
}
|
||||
Some(Module::Node(module)) => module.specifier.clone(),
|
||||
Some(Module::Js(module)) => module.specifier.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue