Opened 6 years ago
Closed 5 years ago
#860 closed defect (fixed)
Prefer empty to size of zero
| Reported by: | goatbar | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 3.6.4 |
| Component: | Default | Version: | 3.6.2 |
| Severity: | Unassigned | Keywords: | |
| Cc: |
Description
double
ElevationMatrixCell::getAvg() const
{
return zvals.size() ?
ztot / static_cast<double>(zvals.size()) :
DoubleNotANumber;
}
Should become:
double
ElevationMatrixCell::getAvg() const
{
return !zvals.empty() ? ztot / static_cast<double>(zvals.size())
: DoubleNotANumber;
}
or better yet, drop the not (!) in the test.
double
ElevationMatrixCell::getAvg() const
{
return zvals.empty()
? DoubleNotANumber
: ztot / static_cast<double>(zvals.size()) ;
}
Note:
See TracTickets
for help on using tickets.

And there are some easy to find instances of the same thing: