diff options
author | Maciej MaĆecki <me@mmalecki.com> | 2014-03-26 04:47:05 +0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-07-31 08:59:46 -0700 |
commit | 4f1ae11a62b97052bc83756f8cb8700cc1f61661 (patch) | |
tree | eef4655e8c1525f97ff09aad9c91a5561b0c2933 | |
parent | 9d281934df9c7f38c4c750640dc7a915315ad125 (diff) | |
download | node-4f1ae11a62b97052bc83756f8cb8700cc1f61661.tar.gz |
module: eliminate double `getenv()`
`process.env` access results in a synchronous `getenv` call. Cache the
first result instead and save one syscall.
-rw-r--r-- | lib/module.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/module.js b/lib/module.js index 77a2a8d18..edca95bd4 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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; |