提交 d43df8b7 编写于 作者: B Benjamin Pasero

remove unneeded cache counting

上级 a84cf69b
...@@ -249,8 +249,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean { ...@@ -249,8 +249,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
*/ */
export let canNormalize = typeof ((<any>'').normalize) === 'function'; export let canNormalize = typeof ((<any>'').normalize) === 'function';
const nonAsciiCharactersPattern = /[^\u0000-\u0080]/; const nonAsciiCharactersPattern = /[^\u0000-\u0080]/;
const normalizedCache = new LinkedMap<string>(10000); const normalizedCache = new LinkedMap<string>(10000); // bounded to 10000 elements
let cacheCounter = 0;
export function normalizeNFC(str: string): string { export function normalizeNFC(str: string): string {
if (!canNormalize || !str) { if (!canNormalize || !str) {
return str; return str;
...@@ -268,11 +267,8 @@ export function normalizeNFC(str: string): string { ...@@ -268,11 +267,8 @@ export function normalizeNFC(str: string): string {
res = str; res = str;
} }
// Use the cache for fast lookup but do not let it grow unbounded // Use the cache for fast lookup
if (cacheCounter < 10000) { normalizedCache.set(str, res);
normalizedCache.set(str, res);
cacheCounter++;
}
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册