[Liblas-commits] libpc: simplify allValid to hop out of testing
once we hit a fal...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 2 11:49:15 EST 2011
details: http://hg.liblas.orglibpc/rev/23076ea40a50
changeset: 155:23076ea40a50
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Mar 02 10:49:11 2011 -0600
description:
simplify allValid to hop out of testing once we hit a false one. Clean up initialization of m_numPoints so it is only set once on construction
diffstat:
src/PointData.cpp | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diffs (41 lines):
diff -r cb18d91a3ee5 -r 23076ea40a50 src/PointData.cpp
--- a/src/PointData.cpp Wed Mar 02 10:39:52 2011 -0600
+++ b/src/PointData.cpp Wed Mar 02 10:49:11 2011 -0600
@@ -48,11 +48,10 @@
PointData::PointData(const SchemaLayout& schemaLayout, boost::uint32_t numPoints) :
m_schemaLayout(schemaLayout),
m_data(NULL),
- m_pointSize(0),
+ m_pointSize(m_schemaLayout.getByteSize()),
m_numPoints(numPoints),
m_isValid(numPoints)
{
- m_pointSize = m_schemaLayout.getByteSize();
m_data = new boost::uint8_t[m_pointSize * m_numPoints];
// the points will all be set to invalid here
@@ -77,17 +76,14 @@
bool PointData::allValid() const
{
- // Assuming each byte is set to 1 for true and 0 for false,
- // if the sum of all of the bytes in the mask == the size
- // of the mask, all the data are valid. This hopefully is faster
- // than walking all of the points individually and doing an
- // if test
+ valid_mask_type::size_type i = 0;
+ while(i < m_isValid.size())
+ {
+ if (m_isValid[i] != 1) return false;
+ i++;
+ }
+ return true;
- boost::uint32_t sum = std::accumulate(m_isValid.begin(), m_isValid.end(), 0);
- if (sum == m_isValid.size())
- return true;
-
- return false;
}
void
More information about the Liblas-commits
mailing list