From c6c6969c3c1d5a975ed213d58a586ec1f1007c33 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 6 Apr 2020 16:43:17 +0200 Subject: [PATCH] use uri-tst for decorations service, https://github.com/microsoft/vscode/issues/93368 --- .../decorations/browser/decorationsService.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/services/decorations/browser/decorationsService.ts b/src/vs/workbench/services/decorations/browser/decorationsService.ts index 208caf240a7..325f4fd609f 100644 --- a/src/vs/workbench/services/decorations/browser/decorationsService.ts +++ b/src/vs/workbench/services/decorations/browser/decorationsService.ts @@ -169,10 +169,10 @@ class DecorationStyles { class FileDecorationChangeEvent implements IResourceDecorationChangeEvent { - private readonly _data = TernarySearchTree.forPaths(); + private readonly _data = TernarySearchTree.forUris(); affectsResource(uri: URI): boolean { - return this._data.get(uri.toString()) || this._data.findSuperstr(uri.toString()) !== undefined; + return this._data.get(uri) || this._data.findSuperstr(uri) !== undefined; } static debouncer(last: FileDecorationChangeEvent | undefined, current: URI | URI[]) { @@ -182,11 +182,11 @@ class FileDecorationChangeEvent implements IResourceDecorationChangeEvent { if (Array.isArray(current)) { // many for (const uri of current) { - last._data.set(uri.toString(), true); + last._data.set(uri, true); } } else { // one - last._data.set(current.toString(), true); + last._data.set(current, true); } return last; @@ -202,7 +202,7 @@ class DecorationDataRequest { class DecorationProviderWrapper { - readonly data = TernarySearchTree.forPaths(); + readonly data = TernarySearchTree.forUris(); private readonly _dispoable: IDisposable; constructor( @@ -234,12 +234,12 @@ class DecorationProviderWrapper { } knowsAbout(uri: URI): boolean { - return Boolean(this.data.get(uri.toString())) || Boolean(this.data.findSuperstr(uri.toString())); + return Boolean(this.data.get(uri)) || Boolean(this.data.findSuperstr(uri)); } getOrRetrieve(uri: URI, includeChildren: boolean, callback: (data: IDecorationData, isChild: boolean) => void): void { - const key = uri.toString(); - let item = this.data.get(key); + + let item = this.data.get(uri); if (item === undefined) { // unknown -> trigger request @@ -253,7 +253,7 @@ class DecorationProviderWrapper { if (includeChildren) { // (resolved) children - const iter = this.data.findSuperstr(key); + const iter = this.data.findSuperstr(uri); if (iter) { for (let item = iter.next(); !item.done; item = iter.next()) { if (item.value && !(item.value instanceof DecorationDataRequest)) { @@ -267,10 +267,10 @@ class DecorationProviderWrapper { private _fetchData(uri: URI): IDecorationData | null { // check for pending request and cancel it - const pendingRequest = this.data.get(uri.toString()); + const pendingRequest = this.data.get(uri); if (pendingRequest instanceof DecorationDataRequest) { pendingRequest.source.cancel(); - this.data.delete(uri.toString()); + this.data.delete(uri); } const source = new CancellationTokenSource(); @@ -282,23 +282,23 @@ class DecorationProviderWrapper { } else { // async -> we have a result soon const request = new DecorationDataRequest(source, Promise.resolve(dataOrThenable).then(data => { - if (this.data.get(uri.toString()) === request) { + if (this.data.get(uri) === request) { this._keepItem(uri, data); } }).catch(err => { - if (!isPromiseCanceledError(err) && this.data.get(uri.toString()) === request) { - this.data.delete(uri.toString()); + if (!isPromiseCanceledError(err) && this.data.get(uri) === request) { + this.data.delete(uri); } })); - this.data.set(uri.toString(), request); + this.data.set(uri, request); return null; } } private _keepItem(uri: URI, data: IDecorationData | undefined): IDecorationData | null { const deco = data ? data : null; - const old = this.data.set(uri.toString(), deco); + const old = this.data.set(uri, deco); if (deco || old) { // only fire event when something changed this._uriEmitter.fire(uri); -- GitLab