From a0e05c3f6a52c54bc6958df6560d3437c58dfe9c Mon Sep 17 00:00:00 2001 From: Lyu Jason Date: Sat, 23 Mar 2024 15:37:14 +0800 Subject: [PATCH] perf: improve perf in deleteUnresolvedResolutionsFromCache --- .../language-server/src/plugins/typescript/module-loader.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/language-server/src/plugins/typescript/module-loader.ts b/packages/language-server/src/plugins/typescript/module-loader.ts index b681978bf..412bf2da1 100644 --- a/packages/language-server/src/plugins/typescript/module-loader.ts +++ b/packages/language-server/src/plugins/typescript/module-loader.ts @@ -64,8 +64,11 @@ class ModuleResolutionCache { const fileNameWithoutEnding = getLastPartOfPath(this.getCanonicalFileName(path)).split('.').shift() || ''; this.cache.forEach((val, key) => { + if (val) { + return; + } const [containingFile, moduleName = ''] = key.split(CACHE_KEY_SEPARATOR); - if (!val && moduleName.includes(fileNameWithoutEnding)) { + if (moduleName.includes(fileNameWithoutEnding)) { this.cache.delete(key); this.pendingInvalidations.add(containingFile); }