diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-22 20:09:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 20:09:12 -0400 |
commit | 7d78e8737f2bb9cd75313c61e3cbf31be5db72f9 (patch) | |
tree | 473fce7fed23e796a929430c56f27238066e54ac /ext/bg/js | |
parent | d395a2a6bfe33feef467f0e0886a089afccd8438 (diff) |
Cache map improvements (#856)
* Update CacheMap API; get=>getOrCreate; add get; add set; add has
* Update tests
* Add more tests
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/json-schema.js | 4 |
1 files changed, 2 insertions, 2 deletions
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; } |