lib: reduce url getters on makeRequireFunction
PR-URL: https://github.com/nodejs/node/pull/48492 Refs: https://github.com/nodejs/performance/issues/92 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
9b61322e02
commit
578ffe1edb
@ -86,8 +86,8 @@ function makeRequireFunction(mod, redirects) {
|
||||
if (destination === true) {
|
||||
missing = false;
|
||||
} else if (destination) {
|
||||
const href = destination.href;
|
||||
if (destination.protocol === 'node:') {
|
||||
const { href, protocol } = destination;
|
||||
if (protocol === 'node:') {
|
||||
const specifier = destination.pathname;
|
||||
|
||||
if (BuiltinModule.canBeRequiredByUsers(specifier)) {
|
||||
@ -95,11 +95,9 @@ function makeRequireFunction(mod, redirects) {
|
||||
return mod.exports;
|
||||
}
|
||||
throw new ERR_UNKNOWN_BUILTIN_MODULE(specifier);
|
||||
} else if (destination.protocol === 'file:') {
|
||||
let filepath;
|
||||
if (urlToFileCache.has(href)) {
|
||||
filepath = urlToFileCache.get(href);
|
||||
} else {
|
||||
} else if (protocol === 'file:') {
|
||||
let filepath = urlToFileCache.get(href);
|
||||
if (!filepath) {
|
||||
filepath = fileURLToPath(destination);
|
||||
urlToFileCache.set(href, filepath);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user