Skip to content

Commit

Permalink
perf: correctly split timestamp by file/dependency and only call getT…
Browse files Browse the repository at this point in the history
…imeInfoEntries once
  • Loading branch information
Mark Molinaro committed Nov 17, 2021
1 parent 64f2bdb commit 72e12ff
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/node/NodeWatchFileSystem.js
Expand Up @@ -68,6 +68,8 @@ class NodeWatchFileSystem {
if (callbackUndelayed) {
this.watcher.once("change", callbackUndelayed);
}

let fileMap, directoryMap;
this.watcher.once("aggregated", (changes, removals) => {
if (this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
Expand All @@ -78,8 +80,10 @@ class NodeWatchFileSystem {
fs.purge(item);
}
}
const times = this.watcher.getTimeInfoEntries();
callback(null, times, times, changes, removals);
fileMap = new Map();
directoryMap = new Map();
this.watcher.getTimeInfoEntries(fileMap, directoryMap);
callback(null, fileMap, directoryMap, changes, removals);
});

this.watcher.watch({ files, directories, missing, startTime });
Expand Down Expand Up @@ -120,18 +124,18 @@ class NodeWatchFileSystem {
return items;
},
getFileTimeInfoEntries: () => {
if (fileMap) return fileMap;
if (this.watcher) {
return this.watcher.getTimeInfoEntries();
} else {
return new Map();
}
return new Map();
},
getContextTimeInfoEntries: () => {
if (directoryMap) return directoryMap;
if (this.watcher) {
return this.watcher.getTimeInfoEntries();
} else {
return new Map();
}
return new Map();
}
};
}
Expand Down

0 comments on commit 72e12ff

Please sign in to comment.