Bug 1339621: Directly add default null collation instead of shifting all elements with unshift(). r=Waldo
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 14 Feb 2017 15:06:24 -0800
changeset 343080 edf262601235c770b8f1638dd75180bc7935ce38
parent 343079 0429b0b495da0839e459b0713e9a39adbd60386f
child 343081 3a90f1f64d8d8cb6fa4aae7e0a322e69671636ae
push id31369
push userkwierso@gmail.com
push dateThu, 16 Feb 2017 00:18:40 +0000
treeherdermozilla-central@e9b926463f9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1339621
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339621: Directly add default null collation instead of shifting all elements with unshift(). r=Waldo
js/src/builtin/Intl.cpp
js/src/builtin/Intl.js
--- a/js/src/builtin/Intl.cpp
+++ b/js/src/builtin/Intl.cpp
@@ -1124,16 +1124,22 @@ js::intl_availableCollations(JSContext* 
         return false;
     }
 
     RootedObject collations(cx, NewDenseEmptyArray(cx));
     if (!collations)
         return false;
 
     uint32_t index = 0;
+
+    // The first element of the collations array must be |null| per
+    // ES2017 Intl, 10.2.3 Internal Slots.
+    if (!DefineElement(cx, collations, index++, NullHandleValue))
+        return false;
+
     for (uint32_t i = 0; i < count; i++) {
         const char* collation = uenum_next(values, nullptr, &status);
         if (U_FAILURE(status)) {
             JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
             return false;
         }
 
         // Per ECMA-402, 10.2.3, we don't include standard and search:
--- a/js/src/builtin/Intl.js
+++ b/js/src/builtin/Intl.js
@@ -1601,20 +1601,18 @@ var collatorInternalProperties = {
         addSpecialMissingLanguageTags(locales);
         return (this._availableLocales = locales);
     },
     relevantExtensionKeys: ["co", "kn"]
 };
 
 
 function collatorSortLocaleData(locale) {
-    var collations = intl_availableCollations(locale);
-    callFunction(std_Array_unshift, collations, null);
     return {
-        co: collations,
+        co: intl_availableCollations(locale),
         kn: ["false", "true"]
     };
 }
 
 
 function collatorSearchLocaleData(locale) {
     return {
         co: [null],