Use IsEmpty() or .empty() to check if a container is empty. NFC.

Most found by clang-tidy.
pull/479/head
Ryan Pavlik 2019-08-20 14:33:23 -05:00 committed by whitequark
parent 61c0167ad7
commit c0904e2ba8
8 changed files with 12 additions and 10 deletions

View File

@ -312,7 +312,7 @@ static bool RunCommand(const std::vector<std::string> args) {
return false;
}
if(inputFiles.size() == 0) {
if(inputFiles.empty()) {
fprintf(stderr, "At least one input file must be specified.\n");
return false;
}

View File

@ -1292,7 +1292,8 @@ public:
void FilterChanged() {
std::string extension = GetExtension();
if(extension == "") return;
if(extension.empty())
return;
Platform::Path path = GetFilename();
SetCurrentName(path.WithExtension(extension).FileName());

View File

@ -203,7 +203,7 @@ static void FindPrefix(const std::string &raw, size_t *pos) {
}
}
#else
if(raw.size() >= 1 && raw[0] == '/') {
if(!raw.empty() && raw[0] == '/') {
*pos = 1;
}
#endif

View File

@ -681,7 +681,8 @@ void SPolygon::MakeEdgesInto(SEdgeList *el) const {
}
Vector SPolygon::ComputeNormal() const {
if(l.n < 1) return Vector::From(0, 0, 0);
if(l.IsEmpty())
return Vector::From(0, 0, 0);
return (l[0]).ComputeNormal();
}

View File

@ -395,7 +395,7 @@ GLuint Generate(const std::vector<double> &pattern) {
int dashI = 0;
double dashT = 0.0;
for(int i = 0; i < size; i++) {
if(pattern.size() == 0) {
if(pattern.empty()) {
textureData[i] = EncodeLengthAsFloat(0.0);
continue;
}

View File

@ -1147,7 +1147,7 @@ PluralExpr::Token PluralExpr::Lex() {
}
PluralExpr::Token PluralExpr::PopToken() {
ssassert(stack.size() > 0, "Expected a non-empty stack");
ssassert(!stack.empty(), "Expected a non-empty stack");
Token t = stack.back();
stack.pop_back();
return t;
@ -1406,7 +1406,7 @@ void GettextParser::Parse() {
}
}
if(key.ident == "") {
if(key.ident.empty()) {
ssassert(msgstrs.size() == 1,
"Expected exactly one header msgstr");
ParseHeader(msgstrs[0]);

View File

@ -476,7 +476,7 @@ void SBezierLoop::MakePwlInto(SContour *sc, double chordTol) const {
}
bool SBezierLoop::IsClosed() const {
if(l.n < 1) return false;
if(l.IsEmpty()) return false;
Vector s = l.First()->Start(),
f = l.Last()->Finish();
return s.Equals(f);
@ -497,7 +497,7 @@ SBezierLoopSet SBezierLoopSet::From(SBezierList *sbl, SPolygon *poly,
SBezierLoopSet ret = {};
*allClosed = true;
while(sbl->l.n > 0) {
while(!sbl->l.IsEmpty()) {
bool thisClosed;
SBezierLoop loop;
loop = SBezierLoop::FromCurves(sbl, &thisClosed, errorAt);

View File

@ -175,7 +175,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my, UiCanvas *canvas,
bool leftpos = true;
for(ToolIcon &icon : Toolbar) {
if(icon.name == "") { // spacer
if(icon.name.empty()) { // spacer
if(!leftpos) {
leftpos = true;
y -= 32;