Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
boingoing authored and pleath committed Mar 6, 2020
1 parent d969210 commit 7e2c360
Show file tree
Hide file tree
Showing 5 changed files with 28,962 additions and 28,996 deletions.
39 changes: 19 additions & 20 deletions lib/Runtime/Library/InJavascript/Intl.js
Expand Up @@ -32,27 +32,27 @@
// We use a raw object rather than a Map because we don't need any features specific to Maps
// If the cache gets too big (arbitrarily, > 25 keys is "too big" by default), we delete the entire internal object and start from scratch
// TODO(jahorto): Experiment with the performance benefit of using an LRU or random-delete cache here.
class IntlCache {
constructor(n = 25) {
this.n = n;
this._cache = _.create();
}
function IntlCache(n = 25) {
return bare({
n: n,
_cache: _.create(),

get(key) {
return platform.useCaches ? this._cache[key] : undefined;
}
get(key) {
return platform.useCaches ? this._cache[key] : undefined;
},

set(key, value) {
if (!platform.useCaches) {
return;
}
set(key, value) {
if (!platform.useCaches) {
return;
}

if (_.keys(this._cache).length > this.n && this._cache[key] === undefined) {
this._cache = _.create();
}
if (_.keys(this._cache).length > this.n && this._cache[key] === undefined) {
this._cache = _.create();
}

this._cache[key] = value;
}
this._cache[key] = value;
}
});
}

var Boolean = platform.Boolean;
Expand All @@ -62,7 +62,6 @@
var String = platform.String;
var Date = platform.Date;
var Error = platform.Error;
var Map = platform.Map;

var RaiseAssert = platform.raiseAssert;

Expand Down Expand Up @@ -2139,10 +2138,10 @@
else {

if (platform.localeLookupCache === undefined) {
platform.localeLookupCache = new platform.Map();
platform.localeLookupCache = new IntlCache();
}
if (platform.localeBestFitCache === undefined) {
platform.localeBestFitCache = new platform.Map();
platform.localeBestFitCache = new IntlCache();
}

let __defaultLocale = undefined;
Expand Down

0 comments on commit 7e2c360

Please sign in to comment.