diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index e0e25f3c8a02f..3e85dd2b60b5c 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -351,11 +351,27 @@ export class TernarySearchTree { return oldElement; } - fill(element: V, keys: readonly K[]): void { - const arr = keys.slice(0); - shuffle(arr); - for (let k of arr) { - this.set(k, element); + /** + * Fill the tree with the same value of the given keys + */ + fill(element: V, keys: readonly K[]): void; + /** + * Fill the tree with given [key,value]-tuples + */ + fill(values: readonly [K, V][]): void; + fill(values: readonly [K, V][] | V, keys?: readonly K[]): void { + if (keys) { + const arr = keys.slice(0); + shuffle(arr); + for (let k of arr) { + this.set(k, (values)); + } + } else { + const arr = (<[K, V][]>values).slice(0); + shuffle(arr); + for (let entry of arr) { + this.set(entry[0], entry[1]); + } } } diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 3b60bb7d6b89c..4d62385058574 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -663,25 +663,31 @@ export class FileChangesEvent { private readonly deleted: TernarySearchTree | undefined = undefined; constructor(changes: readonly IFileChange[], ignorePathCasing: boolean) { + + const entriesByType = new Map(); + for (const change of changes) { - switch (change.type) { + const array = entriesByType.get(change.type); + if (array) { + array.push([change.resource, change]); + } else { + entriesByType.set(change.type, [[change.resource, change]]); + } + } + + for (const [key, value] of entriesByType) { + switch (key) { case FileChangeType.ADDED: - if (!this.added) { - this.added = TernarySearchTree.forUris(() => ignorePathCasing); - } - this.added.set(change.resource, change); + this.added = TernarySearchTree.forUris(() => ignorePathCasing); + this.added.fill(value); break; case FileChangeType.UPDATED: - if (!this.updated) { - this.updated = TernarySearchTree.forUris(() => ignorePathCasing); - } - this.updated.set(change.resource, change); + this.updated = TernarySearchTree.forUris(() => ignorePathCasing); + this.updated.fill(value); break; case FileChangeType.DELETED: - if (!this.deleted) { - this.deleted = TernarySearchTree.forUris(() => ignorePathCasing); - } - this.deleted.set(change.resource, change); + this.deleted = TernarySearchTree.forUris(() => ignorePathCasing); + this.deleted.fill(value); break; } }