Bug 1589415 part 1 - Use StringEqualsAscii in intrinsic_IsRuntimeDefaultLocale. r=anba
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 18 Oct 2019 13:39:04 +0000
changeset 498319 0b3dfc56b00ab50dc60619316705ca4a37c2e4cb
parent 498318 db43f2d8a94310f7d6cf9058e623408e9b011c83
child 498320 d24071361543b312c5fd9ab4b9c413047766711f
push id36717
push usernbeleuzu@mozilla.com
push dateMon, 21 Oct 2019 21:51:55 +0000
treeherdermozilla-central@563f437f24b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1589415
milestone71.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 1589415 part 1 - Use StringEqualsAscii in intrinsic_IsRuntimeDefaultLocale. r=anba Differential Revision: https://phabricator.services.mozilla.com/D49712
js/src/vm/SelfHosting.cpp
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -1773,29 +1773,17 @@ static bool intrinsic_IsRuntimeDefaultLo
     return false;
   }
 
   JSLinearString* str = args[0].toString()->ensureLinear(cx);
   if (!str) {
     return false;
   }
 
-  bool equals;
-  if (str->length() == strlen(locale)) {
-    JS::AutoCheckCannotGC nogc;
-    const Latin1Char* latin1Locale =
-        reinterpret_cast<const Latin1Char*>(locale);
-    equals =
-        str->hasLatin1Chars()
-            ? EqualChars(str->latin1Chars(nogc), latin1Locale, str->length())
-            : EqualChars(str->twoByteChars(nogc), latin1Locale, str->length());
-  } else {
-    equals = false;
-  }
-
+  bool equals = StringEqualsAscii(str, locale);
   args.rval().setBoolean(equals);
   return true;
 }
 #endif  // ENABLE_INTL_API
 
 static bool intrinsic_ThrowArgTypeNotObject(JSContext* cx, unsigned argc,
                                             Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);