Bug 1403911 - Part 7: Fix style nits in jsstr.cpp. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 03 Oct 2017 16:11:07 +0200
changeset 426803 73df32fe6776fddb79774cc63317be1ca2bf4262
parent 426802 763b978156fa9833d5cc3673872b70b6b8d37216
child 426804 a9e829cb93e41884c40f8bdea30eed22e81ccd2b
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersjandem
bugs1403911
milestone58.0a1
Bug 1403911 - Part 7: Fix style nits in jsstr.cpp. r=jandem
js/src/jsstr.cpp
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -2500,17 +2500,18 @@ js::str_trimLeft(JSContext* cx, unsigned
 bool
 js::str_trimRight(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     return TrimString(cx, args, false, true);
 }
 
 // Utility for building a rope (lazy concatenation) of strings.
-class RopeBuilder {
+class RopeBuilder
+{
     JSContext* cx;
     RootedString res;
 
     RopeBuilder(const RopeBuilder& other) = delete;
     void operator=(const RopeBuilder& other) = delete;
 
   public:
     explicit RopeBuilder(JSContext* cx)
@@ -2731,24 +2732,24 @@ BuildDollarReplacement(JSContext* cx, JS
     if (!builder.append(leftSide) || !builder.append(newReplace) || !builder.append(rightSide))
         return nullptr;
 
     return builder.result();
 }
 
 template <typename StrChar, typename RepChar>
 static bool
-StrFlatReplaceGlobal(JSContext *cx, JSLinearString *str, JSLinearString *pat, JSLinearString *rep,
-                     StringBuffer &sb)
+StrFlatReplaceGlobal(JSContext* cx, JSLinearString* str, JSLinearString* pat, JSLinearString* rep,
+                     StringBuffer& sb)
 {
     MOZ_ASSERT(str->length() > 0);
 
     AutoCheckCannotGC nogc;
-    const StrChar *strChars = str->chars<StrChar>(nogc);
-    const RepChar *repChars = rep->chars<RepChar>(nogc);
+    const StrChar* strChars = str->chars<StrChar>(nogc);
+    const RepChar* repChars = rep->chars<RepChar>(nogc);
 
     // The pattern is empty, so we interleave the replacement string in-between
     // each character.
     if (!pat->length()) {
         CheckedInt<uint32_t> strLength(str->length());
         CheckedInt<uint32_t> repLength(rep->length());
         CheckedInt<uint32_t> length = repLength * (strLength - 1) + strLength;
         if (!length.isValid()) {
@@ -2789,18 +2790,18 @@ StrFlatReplaceGlobal(JSContext *cx, JSLi
     if (!sb.append(strChars + start, str->length() - start))
         return false;
 
     return true;
 }
 
 // This is identical to "str.split(pattern).join(replacement)" except that we
 // do some deforestation optimization in Ion.
-JSString *
-js::str_flat_replace_string(JSContext *cx, HandleString string, HandleString pattern,
+JSString*
+js::str_flat_replace_string(JSContext* cx, HandleString string, HandleString pattern,
                             HandleString replacement)
 {
     MOZ_ASSERT(string);
     MOZ_ASSERT(pattern);
     MOZ_ASSERT(replacement);
 
     if (!string->length())
         return string;
@@ -2835,21 +2836,17 @@ js::str_flat_replace_string(JSContext *c
             if (!StrFlatReplaceGlobal<Latin1Char, char16_t>(cx, linearStr, linearPat, linearRepl, sb))
                 return nullptr;
         } else {
             if (!StrFlatReplaceGlobal<Latin1Char, Latin1Char>(cx, linearStr, linearPat, linearRepl, sb))
                 return nullptr;
         }
     }
 
-    JSString *str = sb.finishString();
-    if (!str)
-        return nullptr;
-
-    return str;
+    return sb.finishString();
 }
 
 JSString*
 js::str_replace_string_raw(JSContext* cx, HandleString string, HandleString pattern,
                            HandleString replacement)
 {
     RootedLinearString repl(cx, replacement->ensureLinear(cx));
     if (!repl)
@@ -3051,35 +3048,35 @@ SplitSingleCharHelper(JSContext* cx, Han
     if (!sub || !splits.append(StringValue(sub)))
         return nullptr;
 
     return NewCopiedArrayTryUseGroup(cx, group, splits.begin(), splits.length());
 }
 
 // ES 2016 draft Mar 25, 2016 21.1.3.17 steps 4, 8, 12-18.
 static ArrayObject*
-SplitSingleCharHelper(JSContext* cx, HandleLinearString str, char16_t ch, HandleObjectGroup group) {
-
+SplitSingleCharHelper(JSContext* cx, HandleLinearString str, char16_t ch, HandleObjectGroup group)
+{
     // Step 12.
     size_t strLength = str->length();
 
     AutoStableStringChars linearChars(cx);
     if (!linearChars.init(cx, str))
         return nullptr;
 
     if (linearChars.isLatin1())
         return SplitSingleCharHelper(cx, str, linearChars.latin1Chars(), strLength, ch, group);
 
     return SplitSingleCharHelper(cx, str, linearChars.twoByteChars(), strLength, ch, group);
 }
 
 // ES 2016 draft Mar 25, 2016 21.1.3.17 steps 4, 8, 12-18.
 ArrayObject*
-js::str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep, uint32_t limit)
-
+js::str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep,
+                     uint32_t limit)
 {
     RootedLinearString linearStr(cx, str->ensureLinear(cx));
     if (!linearStr)
         return nullptr;
 
     RootedLinearString linearSep(cx, sep->ensureLinear(cx));
     if (!linearSep)
         return nullptr;
@@ -4622,17 +4619,17 @@ js::FlatStringMatch(JSContext* cx, unsig
     MOZ_ASSERT(args[1].isString());
 #ifdef DEBUG
     bool isOptimizable = false;
     if (!CallIsStringOptimizable(cx, "IsStringMatchOptimizable", &isOptimizable))
         return false;
     MOZ_ASSERT(isOptimizable);
 #endif
 
-    RootedString str(cx,args[0].toString());
+    RootedString str(cx, args[0].toString());
     RootedString pattern(cx, args[1].toString());
 
     bool isFlat = false;
     int32_t match = 0;
     if (!FlatStringMatchHelper(cx, str, pattern, &isFlat, &match))
         return false;
 
     if (!isFlat) {
@@ -4652,17 +4649,17 @@ js::FlatStringSearch(JSContext* cx, unsi
     MOZ_ASSERT(args[1].isString());
 #ifdef DEBUG
     bool isOptimizable = false;
     if (!CallIsStringOptimizable(cx, "IsStringSearchOptimizable", &isOptimizable))
         return false;
     MOZ_ASSERT(isOptimizable);
 #endif
 
-    RootedString str(cx,args[0].toString());
+    RootedString str(cx, args[0].toString());
     RootedString pattern(cx, args[1].toString());
 
     bool isFlat = false;
     int32_t match = 0;
     if (!FlatStringMatchHelper(cx, str, pattern, &isFlat, &match))
         return false;
 
     if (!isFlat) {