[Liblas-commits] hg: attempt to short-circuit scale comparisons when calling SetH...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jun 22 10:39:15 EDT 2011


details:   http://hg.liblas.orghg/rev/85d88e7ce5ea
changeset: 2979:85d88e7ce5ea
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jun 22 09:39:09 2011 -0500
description:
attempt to short-circuit scale comparisons when calling SetHeader

diffstat:

 src/point.cpp |  33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diffs (53 lines):

diff -r 49a24458d49c -r 85d88e7ce5ea src/point.cpp
--- a/src/point.cpp	Tue Jun 21 15:33:18 2011 -0500
+++ b/src/point.cpp	Wed Jun 22 09:39:09 2011 -0500
@@ -204,12 +204,26 @@
     // If we don't have a header initialized, set the point's to the 
     // one we were given.
     if (!m_header) m_header = header;
+
+    // This is hopefully faster than copying everything if we don't have 
+    // any data set and nothing to worry about.
+    const liblas::Schema* schema;
+    boost::uint16_t wanted_length = header.get().GetDataRecordLength();
+    schema = &header.get().GetSchema();
+    boost::uint32_t sum = std::accumulate(m_data.begin(), m_data.end(), 0);
+    
+    if (!sum) {
+        std::vector<boost::uint8_t> data;
+        data.resize(wanted_length);
+        data.assign(wanted_length, 0);
+        m_data = data;
+        m_header = header;
+        return;
+    }
     
     bool bApplyNewScaling = true;
     
-    const liblas::Schema* schema;
-    boost::uint16_t wanted_length = header.get().GetDataRecordLength();
-    schema = &header.get().GetSchema();
+
     
     if (detail::compare_distance(header->GetScaleX(), m_header->GetScaleX()) &&
         detail::compare_distance(header->GetScaleY(), m_header->GetScaleY()) &&
@@ -221,18 +235,7 @@
     else
         bApplyNewScaling = true;
 
-    // This is hopefully faster than copying everything if we don't have 
-    // any data set and nothing to worry about.
-    boost::uint32_t sum = std::accumulate(m_data.begin(), m_data.end(), 0);
-    
-    if (!sum) {
-        std::vector<boost::uint8_t> data;
-        data.resize(wanted_length);
-        data.assign(wanted_length, 0);
-        m_data = data;
-        m_header = header;
-        return;
-    }
+
     
     if (wanted_length != m_data.size())
     {


More information about the Liblas-commits mailing list