From a9d3a477ddc522564abd51a41b6abc4d1f7e083e Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Thu, 17 May 2018 11:54:30 -0700 Subject: [PATCH] EH search - remove slow ES5 async/await from inner loop --- src/vs/workbench/api/node/extHostSearch.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index b520cad5704..6195054e756 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -335,16 +335,22 @@ class QueryGlobTester { /** * Guaranteed async. */ - public async includedInQuery(testPath: string, basename?: string, siblingsFn?: () => string[] | TPromise): TPromise { - if (this._parsedExcludeExpression && await this._parsedExcludeExpression(testPath, basename, siblingsFn)) { - return false; - } + public includedInQuery(testPath: string, basename?: string, siblingsFn?: () => string[] | TPromise): TPromise { + const excludeP = this._parsedExcludeExpression ? + TPromise.as(this._parsedExcludeExpression(testPath, basename, siblingsFn)).then(result => !!result) : + TPromise.wrap(false); - if (this._parsedIncludeExpression && !await this._parsedIncludeExpression(testPath, basename, siblingsFn)) { - return false; - } + return excludeP.then(excluded => { + if (excluded) { + return false; + } - return true; + return this._parsedIncludeExpression ? + TPromise.as(this._parsedIncludeExpression(testPath, basename, siblingsFn)).then(result => !result) : + TPromise.wrap(true); + }).then(included => { + return included; + }); } public hasSiblingExcludeClauses(): boolean {