Skip to content

Commit 26d6502

Browse files
committed
[gardening] Use empty() over size() == 0
1 parent adfead0 commit 26d6502

27 files changed

+43
-43
lines changed

include/swift/Basic/Diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class diff_match_patch {
169169
Patch() : start1(0), start2(0), length1(0), length2(0) {}
170170

171171
bool isNull() const {
172-
return start1 == 0 && start2 == 0 && length1 == 0 && length2 == 0 && diffs.size() == 0;
172+
return start1 == 0 && start2 == 0 && length1 == 0 && length2 == 0 && diffs.empty();
173173
}
174174

175175
/**

include/swift/SILOptimizer/Analysis/BottomUpIPAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class BottomUpIPAnalysis : public SILAnalysis {
181181
}
182182

183183
~BottomUpFunctionOrder() {
184-
assert(InitiallyUnscheduled.size() == 0 &&
184+
assert(InitiallyUnscheduled.empty() &&
185185
"not finished scheduling");
186186
assert(Scheduled.size() == numVisited &&
187187
"missed some functions to schedule");

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4289,7 +4289,7 @@ void DeclName::CompoundDeclName::Profile(llvm::FoldingSetNodeID &id,
42894289

42904290
void DeclName::initialize(ASTContext &C, DeclBaseName baseName,
42914291
ArrayRef<Identifier> argumentNames) {
4292-
if (argumentNames.size() == 0) {
4292+
if (argumentNames.empty()) {
42934293
SimpleOrCompound = BaseNameAndCompound(baseName, true);
42944294
return;
42954295
}

lib/AST/Builtins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static ValueDecl *getBinaryPredicate(Identifier Id, Type ArgType) {
307307
static ValueDecl *getCastOperation(ASTContext &Context, Identifier Id,
308308
BuiltinValueKind VK,
309309
ArrayRef<Type> Types) {
310-
if (Types.size() == 0 || Types.size() > 2) return nullptr;
310+
if (Types.empty() || Types.size() > 2) return nullptr;
311311
Type Input = Types[0];
312312
Type Output = Types.size() == 2 ? Types[1] : Type();
313313

lib/AST/DocComment.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool extractParameterOutline(
141141
L->setChildren(NormalItems);
142142
}
143143

144-
return NormalItems.size() == 0;
144+
return NormalItems.empty();
145145
}
146146

147147
bool extractSeparatedParams(
@@ -205,7 +205,7 @@ bool extractSeparatedParams(
205205
if (NormalItems.size() != Children.size())
206206
L->setChildren(NormalItems);
207207

208-
return NormalItems.size() == 0;
208+
return NormalItems.empty();
209209
}
210210

211211
bool extractSimpleField(
@@ -280,7 +280,7 @@ bool extractSimpleField(
280280
if (NormalItems.size() != Children.size())
281281
L->setChildren(NormalItems);
282282

283-
return NormalItems.size() == 0;
283+
return NormalItems.empty();
284284
}
285285

286286
swift::markup::CommentParts

lib/AST/Expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ packSingleArgument(ASTContext &ctx, SourceLoc lParenLoc, ArrayRef<Expr *> args,
12071207

12081208
// If we have no other arguments, represent the trailing closure as a
12091209
// parenthesized expression.
1210-
if (args.size() == 0) {
1210+
if (args.empty()) {
12111211
auto arg = new (ctx) ParenExpr(lParenLoc, trailingClosure, rParenLoc,
12121212
/*hasTrailingClosure=*/true);
12131213
computeSingleArgumentType(ctx, arg, implicit, getType);

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ ProtocolConformanceRef::getConditionalRequirements() const {
375375
}
376376

377377
void NormalProtocolConformance::differenceAndStoreConditionalRequirements() {
378-
assert(ConditionalRequirements.size() == 0 &&
378+
assert(ConditionalRequirements.empty() &&
379379
"should not recompute conditional requirements");
380380
auto &ctxt = getProtocol()->getASTContext();
381381
auto DC = getDeclContext();

lib/Basic/Version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Optional<Version> Version::parseCompilerVersionString(
114114
bool isValidVersion = true;
115115

116116
auto checkVersionComponent = [&](unsigned Component, SourceRange Range) {
117-
unsigned limit = CV.Components.size() == 0 ? 9223371 : 999;
117+
unsigned limit = CV.Components.empty() ? 9223371 : 999;
118118

119119
if (Component > limit) {
120120
if (Diags)

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,7 @@ ImportedType ClangImporter::Implementation::importAccessorMethodType(
21912191

21922192
// Determine if the method is a property getter or setter.
21932193
bool isGetter;
2194-
if (clangDecl->parameters().size() == 0)
2194+
if (clangDecl->parameters().empty())
21952195
isGetter = true;
21962196
else if (clangDecl->parameters().size() == 1)
21972197
isGetter = false;

lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ ToolChain::constructBatchJob(ArrayRef<const Job *> jobs,
284284
}
285285
}
286286
#endif
287-
if (jobs.size() == 0)
287+
if (jobs.empty())
288288
return nullptr;
289289

290290
// Synthetic OutputInfo is a slightly-modified version of the initial

0 commit comments

Comments
 (0)