Skip to content

Commit

Permalink
Use IsEmpty() or .empty() to check if a container is empty. NFC.
Browse files Browse the repository at this point in the history
Most found by clang-tidy.
  • Loading branch information
rpavlik authored and whitequark committed Sep 10, 2019
1 parent 61c0167 commit c0904e2
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/platform/entrycli.cpp
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/platform/guigtk.cpp
Expand Up @@ -1292,7 +1292,8 @@ class FileDialogImplGtk : public FileDialog {

void FilterChanged() {
std::string extension = GetExtension();
if(extension == "") return;
if(extension.empty())
return;

Platform::Path path = GetFilename();
SetCurrentName(path.WithExtension(extension).FileName());
Expand Down
2 changes: 1 addition & 1 deletion src/platform/platform.cpp
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/polygon.cpp
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/gl3shader.cpp
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/resource.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions src/srf/curve.cpp
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit c0904e2

Please sign in to comment.