diff options
author | Yuval Brik <yuval@brik.org.il> | 2016-04-11 17:48:34 +0300 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2016-04-15 03:46:55 -0400 |
commit | b488b19eaf2b2e7a3ca5eccd2445e245847a5f76 (patch) | |
tree | 51feaa7ff745bd5fcd686c1ed60bb4bc866acb62 /lib/module.js | |
parent | 81fd4581b922079cf059d336d44272c288ea8fdf (diff) | |
download | android-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.tar.gz android-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.tar.bz2 android-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.zip |
fs: optimize realpath using uv_fs_realpath()
Remove realpath() and realpathSync() cache.
Use the native uv_fs_realpath() which is faster
then the JS implementation by a few orders of magnitude.
PR-URL: https://github.com/nodejs/node/pull/3594
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/module.js b/lib/module.js index 8e5dc7a818..29a23776d7 100644 --- a/lib/module.js +++ b/lib/module.js @@ -108,19 +108,10 @@ function tryPackage(requestPath, exts) { tryExtensions(path.resolve(filename, 'index'), exts); } -// In order to minimize unnecessary lstat() calls, -// this cache is a list of known-real paths. -// Set to an empty object to reset. -Module._realpathCache = {}; - // check if the file exists and is not a directory function tryFile(requestPath) { const rc = stat(requestPath); - return rc === 0 && toRealPath(requestPath); -} - -function toRealPath(requestPath) { - return fs.realpathSync(requestPath, Module._realpathCache); + return rc === 0 && fs.realpathSync(requestPath); } // given a path check a the file exists with any of the set extensions @@ -163,7 +154,7 @@ Module._findPath = function(request, paths) { if (!trailingSlash) { const rc = stat(basePath); if (rc === 0) { // File. - filename = toRealPath(basePath); + filename = fs.realpathSync(basePath); } else if (rc === 1) { // Directory. if (exts === undefined) exts = Object.keys(Module._extensions); |