Skip to content

Commit a5af874

Browse files
committed
[clang-format][NFC] Use empty() instead of comparing size() to 0 or 1
1 parent 0fbaeaf commit a5af874

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ bool FormatTokenLexer::tryMergeCSharpKeywordVariables() {
488488

489489
// In C# transform identifier foreach into kw_foreach
490490
bool FormatTokenLexer::tryTransformCSharpForEach() {
491-
if (Tokens.size() < 1)
491+
if (Tokens.empty())
492492
return false;
493493
auto &Identifier = *(Tokens.end() - 1);
494494
if (Identifier->isNot(tok::identifier))
@@ -948,7 +948,7 @@ void FormatTokenLexer::handleTableGenNumericLikeIdentifier() {
948948
// 4. The first non-digit character is 'x', and the next is a hex digit.
949949
// Note that in the case 3 and 4, if the next character does not exists in
950950
// this token, the token is an identifier.
951-
if (Text.size() < 1 || Text[0] == '+' || Text[0] == '-')
951+
if (Text.empty() || Text[0] == '+' || Text[0] == '-')
952952
return;
953953
const auto NonDigitPos = Text.find_if([](char C) { return !isdigit(C); });
954954
// All the characters are digits

clang/lib/Format/MacroExpander.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ MacroExpander::expand(FormatToken *ID,
226226
New->MacroCtx = MacroExpansion(MR_Hidden);
227227
pushToken(New);
228228
}
229-
assert(Result.size() >= 1 && Result.back()->is(tok::eof));
229+
assert(!Result.empty() && Result.back()->is(tok::eof));
230230
if (Result.size() > 1) {
231231
++Result[0]->MacroCtx->StartOfExpansion;
232232
++Result[Result.size() - 2]->MacroCtx->EndOfExpansion;

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4601,7 +4601,7 @@ void UnwrappedLineParser::addUnwrappedLine(LineLevel AdjustLevel) {
46014601
} else {
46024602
// At the top level we only get here when no unexpansion is going on, or
46034603
// when conditional formatting led to unfinished macro reconstructions.
4604-
assert(!Reconstruct || (CurrentLines != &Lines) || PPStack.size() > 0);
4604+
assert(!Reconstruct || (CurrentLines != &Lines) || !PPStack.empty());
46054605
CurrentLines->push_back(std::move(*Line));
46064606
}
46074607
Line->Tokens.clear();

0 commit comments

Comments
 (0)