Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a10ce67

Browse files
committedJun 11, 2015
module: reduce require syscalls
During require search, check the path exists before searching further in it.
1 parent 4b3d493 commit a10ce67

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎lib/module.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const noopDeprecateRequireDot = util.deprecate(function() {},
129129
Module._findPath = function(request, paths) {
130130
var exts = Object.keys(Module._extensions);
131131

132-
if (request.charAt(0) === '/') {
132+
if (path.isAbsolute(request)) {
133133
paths = [''];
134134
}
135135

@@ -142,6 +142,8 @@ Module._findPath = function(request, paths) {
142142

143143
// For each path
144144
for (var i = 0, PL = paths.length; i < PL; i++) {
145+
// Don't search further if path doesn't exist
146+
if (paths[i] && internalModuleStat(paths[i]) < 1) continue;
145147
var basePath = path.resolve(paths[i], request);
146148
var filename;
147149

0 commit comments

Comments
 (0)
Please sign in to comment.