Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 145b668

Browse filesBrowse files
zertoshMyles Borins
authored andcommitted
module: move unnecessary work for early return
The exts and trailingSlash variables are only used if the path isn't cached. This commit moves them further down in the code, and changes from var to const. PR-URL: #3579 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
1 parent f28a640 commit 145b668
Copy full SHA for 145b668

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Collapse file

‎lib/module.js‎

Copy file name to clipboardExpand all lines: lib/module.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,18 @@ function tryExtensions(p, exts) {
126126

127127
var warned = false;
128128
Module._findPath = function(request, paths) {
129-
var exts = Object.keys(Module._extensions);
130-
131129
if (path.isAbsolute(request)) {
132130
paths = [''];
133131
}
134132

135-
var trailingSlash = (request.slice(-1) === '/');
136-
137133
var cacheKey = JSON.stringify({request: request, paths: paths});
138134
if (Module._pathCache[cacheKey]) {
139135
return Module._pathCache[cacheKey];
140136
}
141137

138+
const exts = Object.keys(Module._extensions);
139+
const trailingSlash = request.slice(-1) === '/';
140+
142141
// For each path
143142
for (var i = 0, PL = paths.length; i < PL; i++) {
144143
// Don't search further if path doesn't exist

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.