Bug 1428863 - De-indent TokenStreamSpecific::getDirective a level. r=arai
authorJeff Walden <jwalden@mit.edu>
Wed, 27 Dec 2017 10:21:28 -0500
changeset 399891 325b6c9e845e8857d5666beb574970253fd8d574
parent 399890 118c5618f34898c1dc4fd562401acc6298529c47
child 399892 6349fe7d8cbf246274f39f14456d2b5a70863217
push id33279
push useraciure@mozilla.com
push dateThu, 18 Jan 2018 21:53:37 +0000
treeherdermozilla-central@cffb3cd9dbb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1428863
milestone59.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 1428863 - De-indent TokenStreamSpecific::getDirective a level. r=arai
js/src/frontend/TokenStream.cpp
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1129,69 +1129,76 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                                                          const char* directive,
                                                          uint8_t directiveLength,
                                                          const char* errorMsgPragma,
                                                          UniquePtr<char16_t[], JS::FreePolicy>* destination)
 {
     MOZ_ASSERT(directiveLength <= 18);
     char16_t peeked[18];
 
-    if (peekChars(directiveLength, peeked) && CharsMatch(peeked, directive)) {
-        if (shouldWarnDeprecated) {
-            if (!warning(JSMSG_DEPRECATED_PRAGMA, errorMsgPragma))
-                return false;
-        }
+    // If there aren't enough characters left, it can't be the desired
+    // directive.
+    if (!peekChars(directiveLength, peeked))
+        return true;
+
+    // It's also not the desired directive if the characters don't match.
+    if (!CharsMatch(peeked, directive))
+        return true;
+
+    if (shouldWarnDeprecated) {
+        if (!warning(JSMSG_DEPRECATED_PRAGMA, errorMsgPragma))
+            return false;
+    }
+
+    skipChars(directiveLength);
+    tokenbuf.clear();
 
-        skipChars(directiveLength);
-        tokenbuf.clear();
+    do {
+        int32_t c;
+        if (!peekChar(&c))
+            return false;
+
+        if (c == EOF || unicode::IsSpaceOrBOM2(c))
+            break;
 
-        do {
-            int32_t c;
-            if (!peekChar(&c))
+        consumeKnownChar(c);
+
+        // Debugging directives can occur in both single- and multi-line
+        // comments. If we're currently inside a multi-line comment, we also
+        // need to recognize multi-line comment terminators.
+        if (isMultiline && c == '*') {
+            int32_t c2;
+            if (!peekChar(&c2))
                 return false;
 
-            if (c == EOF || unicode::IsSpaceOrBOM2(c))
+            if (c2 == '/') {
+                ungetChar('*');
                 break;
-
-            consumeKnownChar(c);
-
-            // Debugging directives can occur in both single- and multi-line
-            // comments. If we're currently inside a multi-line comment, we also
-            // need to recognize multi-line comment terminators.
-            if (isMultiline && c == '*') {
-                int32_t c2;
-                if (!peekChar(&c2))
-                    return false;
-
-                if (c2 == '/') {
-                    ungetChar('*');
-                    break;
-                }
             }
-
-            if (!tokenbuf.append(c))
-                return false;
-        } while (true);
-
-        if (tokenbuf.empty()) {
-            // The directive's URL was missing, but this is not quite an
-            // exception that we should stop and drop everything for.
-            return true;
         }
 
-        size_t length = tokenbuf.length();
-
-        *destination = anyCharsAccess().cx->template make_pod_array<char16_t>(length + 1);
-        if (!*destination)
+        if (!tokenbuf.append(c))
             return false;
+    } while (true);
 
-        PodCopy(destination->get(), tokenbuf.begin(), length);
-        (*destination)[length] = '\0';
+    if (tokenbuf.empty()) {
+        // The directive's URL was missing, but this is not quite an
+        // exception that we should stop and drop everything for.
+        return true;
     }
 
+    size_t length = tokenbuf.length();
+
+    *destination = anyCharsAccess().cx->template make_pod_array<char16_t>(length + 1);
+    if (!*destination)
+        return false;
+
+    PodCopy(destination->get(), tokenbuf.begin(), length);
+    (*destination)[length] = '\0';
+
     return true;
 }
 
 template<typename CharT, class AnyCharsAccess>
 bool
 TokenStreamSpecific<CharT, AnyCharsAccess>::getDisplayURL(bool isMultiline,
                                                           bool shouldWarnDeprecated)
 {