[Libreoffice-commits] core.git: dbaccess/source

Tamas Bunth tamas.bunth at collabora.co.uk
Wed May 2 09:12:40 UTC 2018


 dbaccess/source/filter/hsqldb/rowinputbinary.cxx |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 9123711dd092139fb95be92f3ff0cdde657086dd
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Sat Apr 28 12:33:11 2018 +0200

    tdf#117296 dbahsql: Fix migration of numeric
    
    Change-Id: I9ca181c58cd73432c632147870d546d277893fdf
    Reviewed-on: https://gerrit.libreoffice.org/53587
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index a2c736d9b5ac..62c37525367d 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -42,9 +42,8 @@ namespace
 OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
 {
     size_t nbits = 8 * bytes.size(); // length of array in bits
-    size_t nscratch = nbits / 3; // length of scratch in bytes
+    size_t nscratch = nbits / 2; // length of scratch in bytes
     std::vector<char> scratch(nscratch, 0);
-    size_t smin = nscratch - 2; // speed optimization
 
     for (size_t i = 0; i < bytes.size(); ++i)
     {
@@ -54,13 +53,11 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
             int shifted_in = (bytes[i] & (1 << (7 - j))) ? 1 : 0;
 
             /* Add 3 everywhere that scratch[k] >= 5. */
-            for (size_t k = smin; k < nscratch; ++k)
+            for (size_t k = 0; k < nscratch; ++k)
                 scratch[k] += (scratch[k] >= 5) ? 3 : 0;
 
             /* Shift scratch to the left by one position. */
-            if (scratch[smin] >= 8)
-                smin -= 1;
-            for (size_t k = smin; k < nscratch - 1; ++k)
+            for (size_t k = 0; k < nscratch - 1; ++k)
             {
                 scratch[k] <<= 1;
                 scratch[k] &= 0xF;
@@ -76,7 +73,7 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
 
     auto it = scratch.begin();
     /* Remove leading zeros from the scratch space. */
-    while (*it == 0)
+    while (*it == 0 && scratch.size() > 1)
     {
         it = scratch.erase(it);
     }


More information about the Libreoffice-commits mailing list