module: eliminate double getenv()

`process.env` access results in a synchronous `getenv` call. Cache the
first result instead and save one syscall.
This commit is contained in:
Maciej Małecki 2014-03-26 04:47:05 +07:00 committed by Timothy J Fontaine
parent 9d281934df
commit 4f1ae11a62

View File

@ -515,9 +515,10 @@ Module._initPaths = function() {
paths.unshift(path.resolve(homeDir, '.node_modules'));
}
if (process.env['NODE_PATH']) {
var nodePath = process.env['NODE_PATH'];
if (nodePath) {
var splitter = isWindows ? ';' : ':';
paths = process.env['NODE_PATH'].split(splitter).concat(paths);
paths = nodePath.split(splitter).concat(paths);
}
modulePaths = paths;