Kaydet (Commit) 290d192a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Tweak hash generation code to NOT rely on 'i' to shift bits.

Because 'i' can get very large.

Change-Id: I1c7fcafaa60b14f709861f32c56defc7bcaee451
üst 5a637138
...@@ -1386,45 +1386,48 @@ void ScTokenArray::GenHash() ...@@ -1386,45 +1386,48 @@ void ScTokenArray::GenHash()
{ {
// Constant value. // Constant value.
sal_uInt8 nVal = p->GetByte(); sal_uInt8 nVal = p->GetByte();
nHash += (static_cast<size_t>(nVal) << i); nHash += static_cast<size_t>(nVal);
continue;
} }
break;
case svDouble: case svDouble:
{ {
// Constant value. // Constant value.
double fVal = p->GetDouble(); double fVal = p->GetDouble();
nHash += (static_cast<size_t>(fVal) << i); nHash += static_cast<size_t>(fVal);
continue;
} }
break;
case svString: case svString:
{ {
// Constant string. // Constant string.
const String& rStr = p->GetString(); const String& rStr = p->GetString();
nHash += (aHasher(rStr) << i); nHash += aHasher(rStr);
continue;
} }
break;
case svSingleRef: case svSingleRef:
{ {
size_t nVal = HashSingleRef(p->GetSingleRef()); size_t nVal = HashSingleRef(p->GetSingleRef());
nHash += (nVal << i); nHash += nVal;
continue;
} }
break;
case svDoubleRef: case svDoubleRef:
{ {
const ScComplexRefData& rRef = p->GetDoubleRef(); const ScComplexRefData& rRef = p->GetDoubleRef();
size_t nVal1 = HashSingleRef(rRef.Ref1); size_t nVal1 = HashSingleRef(rRef.Ref1);
size_t nVal2 = HashSingleRef(rRef.Ref2); size_t nVal2 = HashSingleRef(rRef.Ref2);
nHash += (nVal1 << i); nHash += nVal1;
nHash += (nVal2 << i); nHash += nVal2;
continue;
} }
break;
default: 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 = (nHash << 4) - nHash;
nHash += (static_cast<size_t>(eOp) << i);
} }
mnHashValue = nHash; mnHashValue = nHash;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment