Opened 7 years ago
Closed 6 years ago
#849 closed defect (fixed)
clang-tidy: readability-container-size-empty size() == 0 can be replaced with empty()
| Reported by: | goatbar | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 3.8.0 |
| Component: | Default | Version: | main |
| Severity: | Unassigned | Keywords: | clangtidy size empty readability-container-size-empty |
| Cc: |
Description
https://clang.llvm.org/extra/clang-tidy/checks/readability-container-size-empty.html
There are at least 9 of these
e.g.
std::size_t
CoordinateArraySequence::getDimension() const
{
if( dimension != 0 )
return dimension;
if( vect->size() == 0 )
return 3;
if( ISNAN((*vect)[0].z) )
dimension = 2;
else
dimension = 3;
return dimension;
}
Could be
std::size_t
CoordinateArraySequence::getDimension() const
{
if( dimension != 0 )
return dimension;
if( vect->empty() ) // <<-- fix here
return 3;
if( ISNAN((*vect)[0].z) )
dimension = 2;
else
dimension = 3;
return dimension;
}
Change History (4)
comment:1 by , 7 years ago
| Summary: | clang-tidy: readability-container-size-empty site() == 0 can be replaced with empty() → clang-tidy: readability-container-size-empty size() == 0 can be replaced with empty() |
|---|
comment:2 by , 6 years ago
| Milestone: | 3.6.3 → 3.8.0 |
|---|
comment:3 by , 6 years ago
Note:
See TracTickets
for help on using tickets.

See #860 for another case:
double ElevationMatrixCell::getAvg() const { return zvals.size() ? // <-- here ztot / static_cast<double>(zvals.size()) : DoubleNotANumber; }