[Liblas-commits] hg-main-tree: avoid small reads at all costs

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Apr 18 17:28:06 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/023ee2d9fa27
changeset: 593:023ee2d9fa27
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Apr 18 14:27:50 2011 -0700
description:
avoid small reads at all costs

diffstat:

 src/drivers/las/Reader.cpp |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (30 lines):

diff -r 5ad49de6335d -r 023ee2d9fa27 src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp	Mon Apr 18 14:03:15 2011 -0700
+++ b/src/drivers/las/Reader.cpp	Mon Apr 18 14:27:50 2011 -0700
@@ -126,14 +126,12 @@
     const bool hasColor = Support::hasColor(pointFormat);
     const int pointByteCount = Support::getPointDataSize(pointFormat);
 
-    assert(100 > pointByteCount);
-    boost::uint8_t buf[100]; // set to something larger than the largest point format requires
+    boost::uint8_t* buf = new boost::uint8_t[pointByteCount * numPoints];
+    Utils::read_n(buf, stream, pointByteCount * numPoints);
 
     for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
     {
-        Utils::read_n(buf, stream, pointByteCount);
-
-        boost::uint8_t* p = buf;
+        boost::uint8_t* p = buf + pointByteCount * pointIndex;
 
         // always read the base fields
         {
@@ -186,6 +184,8 @@
         data.setNumPoints(pointIndex+1);
     }
 
+    delete[] buf;
+
     return numPoints;
 }
 


More information about the Liblas-commits mailing list