Skip to content

Commit

Permalink
[clang-format][NFC] AlignTokenSequence: Skip loop iteration
Browse files Browse the repository at this point in the history
When Shift is 0 there does nothing happen in the remainder of the loop,
express that directly.
  • Loading branch information
HazardyKnusperkeks committed Oct 4, 2023
1 parent b7ac16c commit b6f2919
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clang/lib/Format/WhitespaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
}
}

if (Shift == 0)
continue;

// This is for function parameters that are split across multiple lines,
// as mentioned in the ScopeStack comment.
if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) {
Expand Down Expand Up @@ -447,7 +450,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
CurrentChange.Spaces += Shift;

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

0 comments on commit b6f2919

Please sign in to comment.