From d43df8b75b3f46fdb004bf4e0e5f2d761d254ac1 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 30 Apr 2016 17:00:22 +0200 Subject: [PATCH] remove unneeded cache counting --- src/vs/base/common/strings.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index eac353543c2..a3b7e37958e 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; } -- GitLab