diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index eac353543c223b7ce2acba42ce685fbd857ee05c..a3b7e37958e3f9c85d9d1715c4034564fae931e0 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -249,8 +249,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean { */ export let canNormalize = typeof (('').normalize) === 'function'; const nonAsciiCharactersPattern = /[^\u0000-\u0080]/; -const normalizedCache = new LinkedMap(10000); -let cacheCounter = 0; +const normalizedCache = new LinkedMap(10000); // bounded to 10000 elements export function normalizeNFC(str: string): string { if (!canNormalize || !str) { return str; @@ -268,11 +267,8 @@ export function normalizeNFC(str: string): string { res = str; } - // Use the cache for fast lookup but do not let it grow unbounded - if (cacheCounter < 10000) { - normalizedCache.set(str, res); - cacheCounter++; - } + // Use the cache for fast lookup + normalizedCache.set(str, res); return res; }