From cfce9c21da272a28cb77aea32352c6ac53ac68fc Mon Sep 17 00:00:00 2001 From: Bartlomiej Brzozowski Date: Fri, 12 Jun 2020 14:04:11 +0200 Subject: [PATCH] win,fs: improve realpathSync performance Moving knownHard object improves realpathSync perfomance. This results in require being 10% faster on Windows and realpathSync itself 50x faster. Ref: https://github.com/nodejs/node/issues/28946 --- lib/fs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fs.js b/lib/fs.js index b0581927514888..3c1e964d22d815 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1562,6 +1562,7 @@ if (isWindows) { } const emptyObj = ObjectCreate(null); +const knownHard = ObjectCreate(null); function realpathSync(p, options) { if (!options) options = emptyObj; @@ -1581,7 +1582,6 @@ function realpathSync(p, options) { } const seenLinks = ObjectCreate(null); - const knownHard = ObjectCreate(null); const original = p; // Current character position in p