Bug 1504464 - Part 6: Rearrange control flow in ReadableStream_getReader slightly to resemble the standard steps. r=jwalden
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 14 Jan 2019 20:33:30 +0000
changeset 510920 7afcd486bdc615bbdca8a9afd432c61299441a4b
parent 510919 de74494a1aa7ddfbc6a6475b8e2c3a91eba4dad9
child 510921 8a450893e90a2b4fb9e8fdc5328e6622026ad6eb
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1504464
milestone66.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 1504464 - Part 6: Rearrange control flow in ReadableStream_getReader slightly to resemble the standard steps. r=jwalden No change in behavior. Differential Revision: https://phabricator.services.mozilla.com/D14504
js/src/builtin/Stream.cpp
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -561,21 +561,21 @@ bool ReadableStream::constructor(JSConte
 
   // Step 5: Let typeString be ? ToString(type).
   RootedString typeString(cx, ToString<CanGC>(cx, type));
   if (!typeString) {
     return false;
   }
 
   // Step 6: If typeString is "bytes",
-  int32_t cmp;
-  if (!CompareStrings(cx, typeString, cx->names().bytes, &cmp)) {
+  bool equal;
+  if (!EqualStrings(cx, typeString, cx->names().bytes, &equal)) {
     return false;
   }
-  if (cmp == 0) {
+  if (equal) {
     // The rest of step 6 is unimplemented, since we don't support
     // user-defined byte streams yet.
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
                               JSMSG_READABLESTREAM_BYTES_TYPE_NOT_IMPLEMENTED);
     return false;
   }
 
   // Step 7: Otherwise, if type is undefined,
@@ -713,29 +713,31 @@ static bool ReadableStream_getReader(JSC
     // Step 3: Set mode to ? ToString(mode) (implicit).
     RootedString mode(cx, ToString<CanGC>(cx, modeVal));
     if (!mode) {
       return false;
     }
 
     // Step 4: If mode is "byob",
     //         return ? AcquireReadableStreamBYOBReader(this).
-    int32_t notByob;
-    if (!CompareStrings(cx, mode, cx->names().byob, &notByob)) {
+    bool equal;
+    if (!EqualStrings(cx, mode, cx->names().byob, &equal)) {
       return false;
     }
-    if (notByob) {
-      JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
-                                JSMSG_READABLESTREAM_INVALID_READER_MODE);
-      // Step 5: Throw a RangeError exception.
+    if (equal) {
+      JS_ReportErrorNumberASCII(
+          cx, GetErrorMessage, nullptr,
+          JSMSG_READABLESTREAM_BYTES_TYPE_NOT_IMPLEMENTED);
       return false;
     }
 
+    // Step 5: Throw a RangeError exception.
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
-                              JSMSG_READABLESTREAM_BYTES_TYPE_NOT_IMPLEMENTED);
+                              JSMSG_READABLESTREAM_INVALID_READER_MODE);
+    return false;
   }
 
   // Reordered second part of steps 2 and 4.
   if (!reader) {
     return false;
   }
   args.rval().setObject(*reader);
   return true;