fs: cache non-symlinks in realpathSync.

Extend `fs.realpathSync` to cache the results for paths that are not
symlinks in addition to caching symlink mappings.

PR-URL: https://github.com/nodejs/node/pull/10253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Jeremy Yallop 2016-12-12 15:56:36 +00:00 committed by James M Snell
parent 17eb8fce05
commit 5dc44874c3

View File

@ -1528,6 +1528,7 @@ fs.realpathSync = function realpathSync(p, options) {
var stat = fs.lstatSync(base);
if (!stat.isSymbolicLink()) {
knownHard[base] = true;
if (cache) cache.set(base, base);
continue;
}