From 4abe9b3bae4dda1b5885f82483f1d69177869333 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei-Da" <36730922+jasonlyu123@users.noreply.github.com> Date: Sat, 23 Mar 2024 16:02:47 +0800 Subject: [PATCH] perf: improve perf in deleteUnresolvedResolutionsFromCache (#2320) --- .../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); }