From 7d78e8737f2bb9cd75313c61e3cbf31be5db72f9 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 22 Sep 2020 20:09:12 -0400 Subject: Cache map improvements (#856) * Update CacheMap API; get=>getOrCreate; add get; add set; add has * Update tests * Add more tests --- ext/bg/js/json-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index 357432e5..4d77f0db 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -125,7 +125,7 @@ class JsonSchemaProxyHandler { class JsonSchemaValidator { constructor() { - this._regexCache = new CacheMap(100, (pattern, flags) => new RegExp(pattern, flags)); + this._regexCache = new CacheMap(100, ([pattern, flags]) => new RegExp(pattern, flags)); } createProxy(target, schema) { @@ -676,7 +676,7 @@ class JsonSchemaValidator { } _getRegex(pattern, flags) { - const regex = this._regexCache.get(pattern, flags); + const regex = this._regexCache.getOrCreate([pattern, flags]); regex.lastIndex = 0; return regex; } -- cgit v1.2.3