From 695b307cc672f0663905b833609bd6370fe5ab36 Mon Sep 17 00:00:00 2001 From: 243083df <243083df@dispostable.com> Date: Tue, 10 Oct 2017 19:38:45 +0400 Subject: [PATCH] module: minor performance improvement PR-URL: https://github.com/nodejs/node/pull/16125 Reviewed-By: Anna Henningsen --- lib/module.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/module.js b/lib/module.js index 73f3cc8dd8..a99da2358d 100644 --- a/lib/module.js +++ b/lib/module.js @@ -218,14 +218,9 @@ Module._findPath = function(request, paths, isMain) { if (!filename && rc === 1) { // Directory. if (exts === undefined) exts = Object.keys(Module._extensions); - filename = tryPackage(basePath, exts, isMain); - } - - if (!filename && rc === 1) { // Directory. - // try it with each of the extensions at "index" - if (exts === undefined) - exts = Object.keys(Module._extensions); - filename = tryExtensions(path.resolve(basePath, 'index'), exts, isMain); + filename = tryPackage(basePath, exts, isMain) || + // try it with each of the extensions at "index" + tryExtensions(path.resolve(basePath, 'index'), exts, isMain); } if (filename) {