[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Mar 19 06:40:42 PDT 2013


 sc/source/core/tool/token.cxx |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

New commits:
commit 11c4471b68c1830134daf81f8aea0cc9b3dd9b59
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 19 09:40:43 2013 -0400

    Tweak hash generation code to NOT rely on 'i' to shift bits.
    
    Because 'i' can get very large.
    
    Change-Id: I1c7fcafaa60b14f709861f32c56defc7bcaee451

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6368ba7..85d6e9a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1386,45 +1386,48 @@ void ScTokenArray::GenHash()
                 {
                     // Constant value.
                     sal_uInt8 nVal = p->GetByte();
-                    nHash += (static_cast<size_t>(nVal) << i);
-                    continue;
+                    nHash += static_cast<size_t>(nVal);
                 }
+                break;
                 case svDouble:
                 {
                     // Constant value.
                     double fVal = p->GetDouble();
-                    nHash += (static_cast<size_t>(fVal) << i);
-                    continue;
+                    nHash += static_cast<size_t>(fVal);
                 }
+                break;
                 case svString:
                 {
                     // Constant string.
                     const String& rStr = p->GetString();
-                    nHash += (aHasher(rStr) << i);
-                    continue;
+                    nHash += aHasher(rStr);
                 }
+                break;
                 case svSingleRef:
                 {
                     size_t nVal = HashSingleRef(p->GetSingleRef());
-                    nHash += (nVal << i);
-                    continue;
+                    nHash += nVal;
                 }
+                break;
                 case svDoubleRef:
                 {
                     const ScComplexRefData& rRef = p->GetDoubleRef();
                     size_t nVal1 = HashSingleRef(rRef.Ref1);
                     size_t nVal2 = HashSingleRef(rRef.Ref2);
-                    nHash += (nVal1 << i);
-                    nHash += (nVal2 << i);
-                    continue;
+                    nHash += nVal1;
+                    nHash += nVal2;
                 }
+                break;
                 default:
-                    ;
+                    // Use the opcode value in all the other cases.
+                    nHash += static_cast<size_t>(eOp);
             }
         }
+        else
+            // Use the opcode value in all the other cases.
+            nHash += static_cast<size_t>(eOp);
 
-        // Use the opcode value in all the other cases.
-        nHash += (static_cast<size_t>(eOp) << i);
+        nHash = (nHash << 4) - nHash;
     }
 
     mnHashValue = nHash;


More information about the Libreoffice-commits mailing list