From 8151f6af4754a247b421d0554001195219c1bd1b Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Wed, 16 Oct 2024 12:32:58 +0200 Subject: [PATCH] WIP --- core/local/chokidar/analysis.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/local/chokidar/analysis.js b/core/local/chokidar/analysis.js index d028f01ca..bf58dcbff 100644 --- a/core/local/chokidar/analysis.js +++ b/core/local/chokidar/analysis.js @@ -72,7 +72,7 @@ module.exports = function analysis( class LocalChangeMap { /*:: - changes: LocalChange[] + changes: Set changesByInode: Map changesByPath: Map */ @@ -82,7 +82,7 @@ class LocalChangeMap { } _clear() { - this.changes = [] + this.changes = new Set() this.changesByInode = new Map() this.changesByPath = new Map() } @@ -108,8 +108,8 @@ class LocalChangeMap { if (typeof toReplace.ino === 'number') { this.changesByInode.set(toReplace.ino, c) } else { - const index = this.changes.indexOf(toReplace) - this.changes.splice(index, 1, c) + this.changes.delete(toReplace) + this.changes.add(c) } } else { this.changesByPath.set(c.path.normalize(), c) @@ -117,16 +117,16 @@ class LocalChangeMap { if (typeof c.ino === 'number') { this.changesByInode.set(c.ino, c) } else { - this.changes.push(c) + this.changes.add(c) } } } flush() /*: LocalChange[] */ { const changes = this.changes - for (let a of this.changesByInode.values()) changes.push(a) + for (let a of this.changesByInode.values()) changes.add(a) this._clear() - return changes + return Array.from(changes) } } @@ -157,7 +157,7 @@ function analyseEvents( log.trace('Analyze events...') - for (let e /*: LocalEvent */ of events) { + for (const e /*: LocalEvent */ of events) { if (process.env.DEBUG) log.trace({ currentEvent: e, path: e.path }) try { // chokidar make mistakes