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

Generate token array hash exactly once, when the string is tokenized.

And CompileString() is the place to do it, to the best of my knowledge.

Change-Id: I249df5d09aa288eacc2b2c7ad6e5fc947a3c225f
üst 0a0deec6
...@@ -35,6 +35,8 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray ...@@ -35,6 +35,8 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray
friend class ScCompiler; friend class ScCompiler;
bool ImplGetReference( ScRange& rRange, bool bValidOnly ) const; bool ImplGetReference( ScRange& rRange, bool bValidOnly ) const;
size_t mnHashValue;
public: public:
ScTokenArray(); ScTokenArray();
/// Assignment with references to ScToken entries (not copied!) /// Assignment with references to ScToken entries (not copied!)
...@@ -42,6 +44,7 @@ public: ...@@ -42,6 +44,7 @@ public:
virtual ~ScTokenArray(); virtual ~ScTokenArray();
ScTokenArray* Clone() const; /// True copy! ScTokenArray* Clone() const; /// True copy!
void GenHash();
size_t GetHash() const; size_t GetHash() const;
/// Exactly and only one range (valid or deleted) /// Exactly and only one range (valid or deleted)
......
...@@ -3951,6 +3951,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula ) ...@@ -3951,6 +3951,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula )
// remember pArr, in case a subsequent CompileTokenArray() is executed. // remember pArr, in case a subsequent CompileTokenArray() is executed.
ScTokenArray* pNew = new ScTokenArray( aArr ); ScTokenArray* pNew = new ScTokenArray( aArr );
pNew->GenHash();
pArr = pNew; pArr = pNew;
if (!maExternalFiles.empty()) if (!maExternalFiles.empty())
......
...@@ -1294,7 +1294,7 @@ size_t HashSingleRef( const ScSingleRefData& rRef ) ...@@ -1294,7 +1294,7 @@ size_t HashSingleRef( const ScSingleRefData& rRef )
} }
size_t ScTokenArray::GetHash() const void ScTokenArray::GenHash()
{ {
static OUStringHash aHasher; static OUStringHash aHasher;
...@@ -1357,7 +1357,13 @@ size_t ScTokenArray::GetHash() const ...@@ -1357,7 +1357,13 @@ size_t ScTokenArray::GetHash() const
// Use the opcode value in all the other cases. // Use the opcode value in all the other cases.
nHash += (static_cast<size_t>(eOp) << i); nHash += (static_cast<size_t>(eOp) << i);
} }
return nHash;
mnHashValue = nHash;
}
size_t ScTokenArray::GetHash() const
{
return mnHashValue;
} }
bool ScTokenArray::IsReference( ScRange& rRange ) const bool ScTokenArray::IsReference( ScRange& rRange ) const
...@@ -1372,11 +1378,15 @@ bool ScTokenArray::IsValidReference( ScRange& rRange ) const ...@@ -1372,11 +1378,15 @@ bool ScTokenArray::IsValidReference( ScRange& rRange ) const
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
ScTokenArray::ScTokenArray() ScTokenArray::ScTokenArray() :
FormulaTokenArray(),
mnHashValue(0)
{ {
} }
ScTokenArray::ScTokenArray( const ScTokenArray& rArr ) : FormulaTokenArray(rArr) ScTokenArray::ScTokenArray( const ScTokenArray& rArr ) :
FormulaTokenArray(rArr),
mnHashValue(rArr.mnHashValue)
{ {
} }
...@@ -1384,8 +1394,6 @@ ScTokenArray::~ScTokenArray() ...@@ -1384,8 +1394,6 @@ ScTokenArray::~ScTokenArray()
{ {
} }
ScTokenArray& ScTokenArray::operator=( const ScTokenArray& rArr ) ScTokenArray& ScTokenArray::operator=( const ScTokenArray& rArr )
{ {
Clear(); Clear();
...@@ -1402,6 +1410,7 @@ ScTokenArray* ScTokenArray::Clone() const ...@@ -1402,6 +1410,7 @@ ScTokenArray* ScTokenArray::Clone() const
p->nMode = nMode; p->nMode = nMode;
p->nError = nError; p->nError = nError;
p->bHyperLink = bHyperLink; p->bHyperLink = bHyperLink;
p->mnHashValue = mnHashValue;
FormulaToken** pp; FormulaToken** pp;
if( nLen ) if( nLen )
{ {
......
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