Skip to content

Commit b6f2919

Browse files
[clang-format][NFC] AlignTokenSequence: Skip loop iteration
When Shift is 0 there does nothing happen in the remainder of the loop, express that directly.
1 parent b7ac16c commit b6f2919

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
354354
}
355355
}
356356

357+
if (Shift == 0)
358+
continue;
359+
357360
// This is for function parameters that are split across multiple lines,
358361
// as mentioned in the ScopeStack comment.
359362
if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) {
@@ -447,7 +450,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
447450
CurrentChange.Spaces += Shift;
448451

449452
// We should not remove required spaces unless we break the line before.
450-
assert(Shift >= 0 || Changes[i].NewlinesBefore > 0 ||
453+
assert(Shift > 0 || Changes[i].NewlinesBefore > 0 ||
451454
CurrentChange.Spaces >=
452455
static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) ||
453456
CurrentChange.Tok->is(tok::eof));

0 commit comments

Comments
 (0)