[geos-devel] [GEOS] #860: Prefer empty to size of zero
GEOS
geos-trac at osgeo.org
Wed Feb 28 06:29:45 PST 2018
#860: Prefer empty to size of zero
------------------------+--------------------------
Reporter: goatbar | Owner: geos-devel@…
Type: defect | Status: new
Priority: major | Milestone: 3.6.3
Component: Default | Version: 3.6.2
Severity: Unassigned | Keywords:
------------------------+--------------------------
{{{#!c++
double
ElevationMatrixCell::getAvg() const
{
return zvals.size() ?
ztot / static_cast<double>(zvals.size()) :
DoubleNotANumber;
}
}}}
Should become:
{{{#!c++
double
ElevationMatrixCell::getAvg() const
{
return !zvals.empty() ? ztot / static_cast<double>(zvals.size())
: DoubleNotANumber;
}
}}}
or better yet, drop the not (!) in the test.
{{{#!c++
double
ElevationMatrixCell::getAvg() const
{
return zvals.empty()
? DoubleNotANumber
: ztot / static_cast<double>(zvals.size()) ;
}
}}}
--
Ticket URL: <https://trac.osgeo.org/geos/ticket/860>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).
More information about the geos-devel
mailing list