Skip to content

Commit 4f1ae11

Browse files
mmaleckitjfontaine
authored andcommitted
module: eliminate double getenv()
`process.env` access results in a synchronous `getenv` call. Cache the first result instead and save one syscall.
1 parent 9d28193 commit 4f1ae11

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/module.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,10 @@ Module._initPaths = function() {
515515
paths.unshift(path.resolve(homeDir, '.node_modules'));
516516
}
517517

518-
if (process.env['NODE_PATH']) {
518+
var nodePath = process.env['NODE_PATH'];
519+
if (nodePath) {
519520
var splitter = isWindows ? ';' : ':';
520-
paths = process.env['NODE_PATH'].split(splitter).concat(paths);
521+
paths = nodePath.split(splitter).concat(paths);
521522
}
522523

523524
modulePaths = paths;

0 commit comments

Comments
 (0)