JavaScript:SpiderMonkey:C++ Coding Style: Difference between revisions

Line 43: Line 43:
  }
  }


Conditions with multi-line tests should put the brace on the new line.
Conditions with multi-line tests should put the brace on the new line to provide a visual separation.


   types::TypeSet *types = frame.extra(lhs).types;
   types::TypeSet *types = frame.extra(lhs).types;
Line 58: Line 58:
   } else {
   } else {
       ...
       ...
  }
However, if there is already a visual separation between the condition and the body, putting the { on a new line isn't necessary:
  if (forHead->pn_kid1 && NewSrcNote2(cx, cg, SRC_DECL,
                                      (forHead->pn_kid1->isOp(JSOP_DEFVAR))
                                      ? SRC_DECL_VAR
                                      : SRC_DECL_LET) < 0) {
      return false;
   }
   }


Confirmed users
367

edits