[Liblas-commits] laszip: small efficiency fix

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jan 31 16:35:54 EST 2011


details:   http://hg.liblas.orglaszip/rev/729745b3b317
changeset: 173:729745b3b317
user:      isenburg
date:      Mon Jan 31 13:35:44 2011 -0800
description:
small efficiency fix

diffstat:

 src/arithmeticdecoder.cpp |   8 ++++----
 src/arithmeticencoder.cpp |  12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diffs (62 lines):

diff -r a372803f1069 -r 729745b3b317 src/arithmeticdecoder.cpp
--- a/src/arithmeticdecoder.cpp	Mon Jan 31 13:22:30 2011 -0800
+++ b/src/arithmeticdecoder.cpp	Mon Jan 31 13:35:44 2011 -0800
@@ -263,10 +263,10 @@
 {
   U32 lowerInt = readShort();
   U32 upperInt = readShort();
-  return upperInt*U16_MAX_PLUS_ONE+lowerInt;
+  return (upperInt<<16)|lowerInt;
 }
 
-inline F32 ArithmeticDecoder::readFloat()
+inline F32 ArithmeticDecoder::readFloat() /* danger in float reinterpretation */
 {
   U32I32F32 u32i32f32;
   u32i32f32.u32 = readInt();
@@ -277,10 +277,10 @@
 {
   U64 lowerInt = readInt();
   U64 upperInt = readInt();
-  return upperInt*U32_MAX_PLUS_ONE+lowerInt;
+  return (upperInt<<32)|lowerInt;
 }
 
-inline F64 ArithmeticDecoder::readDouble()
+inline F64 ArithmeticDecoder::readDouble() /* danger in float reinterpretation */
 {
   U64I64F64 u64i64f64;
   u64i64f64.u64 = readInt64();
diff -r a372803f1069 -r 729745b3b317 src/arithmeticencoder.cpp
--- a/src/arithmeticencoder.cpp	Mon Jan 31 13:22:30 2011 -0800
+++ b/src/arithmeticencoder.cpp	Mon Jan 31 13:35:44 2011 -0800
@@ -262,11 +262,11 @@
 
 inline void ArithmeticEncoder::writeInt(U32 sym)
 {
-  writeShort((U16)(sym % U16_MAX_PLUS_ONE)); // lower 16 bits
-  writeShort((U16)(sym / U16_MAX_PLUS_ONE)); // UPPER 16 bits
+  writeShort((U16)(sym & 0xFFFF)); // lower 16 bits
+  writeShort((U16)(sym >> 16));    // UPPER 16 bits
 }
 
-inline void ArithmeticEncoder::writeFloat(F32 sym)
+inline void ArithmeticEncoder::writeFloat(F32 sym) /* danger in float reinterpretation */
 {
   U32I32F32 u32i32f32;
   u32i32f32.f32 = sym;
@@ -275,11 +275,11 @@
 
 inline void ArithmeticEncoder::writeInt64(U64 sym)
 {
-  writeInt((U32)(sym % U32_MAX_PLUS_ONE)); // lower 32 bits
-  writeInt((U32)(sym / U32_MAX_PLUS_ONE)); // UPPER 32 bits
+  writeInt((U32)(sym & 0xFFFFFFFF)); // lower 32 bits
+  writeInt((U32)(sym >> 32));        // UPPER 32 bits
 }
 
-inline void ArithmeticEncoder::writeDouble(F64 sym)
+inline void ArithmeticEncoder::writeDouble(F64 sym) /* danger in float reinterpretation */
 {
   U64I64F64 u64i64f64;
   u64i64f64.f64 = sym;


More information about the Liblas-commits mailing list