Skip to content

Commit 593a00c

Browse files
committed
Merge #9506: RFC: Improve style for if indentation
74994c6 Improve style w.r.t. if (Pieter Wuille)
2 parents bbf193f + 74994c6 commit 593a00c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

doc/developer-notes.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ gradually.
1111
- Braces on new lines for namespaces, classes, functions, methods.
1212
- Braces on the same line for everything else.
1313
- 4 space indentation (no tabs) for every block except namespaces.
14-
- No indentation for public/protected/private or for namespaces.
14+
- No indentation for `public`/`protected`/`private` or for `namespace`.
1515
- No extra spaces inside parenthesis; don't do ( this )
16-
- No space after function names; one space after if, for and while.
16+
- No space after function names; one space after `if`, `for` and `while`.
17+
- If an `if` only has a single-statement then-clause, it can appear
18+
on the same line as the if, without braces. In every other case,
19+
braces are required, and the then and else clauses must appear
20+
correctly indented on a new line.
1721
- `++i` is preferred over `i++`.
1822

1923
Block style example:
@@ -22,14 +26,18 @@ namespace foo
2226
{
2327
class Class
2428
{
25-
bool Function(char* psz, int n)
29+
bool Function(const std::string& s, int n)
2630
{
2731
// Comment summarising what this section of code does
2832
for (int i = 0; i < n; ++i) {
2933
// When something fails, return early
30-
if (!Something())
31-
return false;
34+
if (!Something()) return false;
3235
...
36+
if (SomethingElse()) {
37+
DoMore();
38+
} else {
39+
DoLess();
40+
}
3341
}
3442

3543
// Success return is usually at the end

0 commit comments

Comments
 (0)