Bug 1319843 - Part 2: Validate current locale matches cached locale for Number.toLocaleString() and String.localeCompare(). r=gandalf

This commit is contained in:
André Bargull 2017-11-24 05:09:49 -08:00
parent 15df3c49ab
commit 218f82fd82
2 changed files with 8 additions and 4 deletions

View File

@ -28,8 +28,10 @@ function Number_toLocaleString() {
if (locales === undefined && options === undefined) {
// This cache only optimizes for the old ES5 toLocaleString without
// locales and options.
if (numberFormatCache.numberFormat === undefined)
if (!IsRuntimeDefaultLocale(numberFormatCache.runtimeDefaultLocale)) {
numberFormatCache.numberFormat = intl_NumberFormat(locales, options);
numberFormatCache.runtimeDefaultLocale = RuntimeDefaultLocale();
}
numberFormat = numberFormatCache.numberFormat;
} else {
numberFormat = intl_NumberFormat(locales, options);

View File

@ -490,8 +490,6 @@ function String_codePointAt(pos) {
return (first - 0xD800) * 0x400 + (second - 0xDC00) + 0x10000;
}
var collatorCache = new Record();
/* ES6 20121122 draft 15.5.4.21. */
function String_repeat(count) {
// Steps 1-3.
@ -572,6 +570,8 @@ function StringIteratorNext() {
return result;
}
var collatorCache = new Record();
/**
* Compare this String against that String, using the locale and collation
* options provided.
@ -593,8 +593,10 @@ function String_localeCompare(that) {
if (locales === undefined && options === undefined) {
// This cache only optimizes for the old ES5 localeCompare without
// locales and options.
if (collatorCache.collator === undefined)
if (!IsRuntimeDefaultLocale(collatorCache.runtimeDefaultLocale)) {
collatorCache.collator = intl_Collator(locales, options);
collatorCache.runtimeDefaultLocale = RuntimeDefaultLocale();
}
collator = collatorCache.collator;
} else {
collator = intl_Collator(locales, options);