[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Mar 18 16:38:35 PDT 2013
sc/inc/tokenarray.hxx | 3 +++
sc/source/core/tool/compiler.cxx | 1 +
sc/source/core/tool/token.cxx | 21 +++++++++++++++------
3 files changed, 19 insertions(+), 6 deletions(-)
New commits:
commit 526782001ff6ab3110ef1da6e114eb0c738ce6e3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Mar 18 19:40:08 2013 -0400
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
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 01993e9..e3b7d56 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -35,6 +35,8 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray
friend class ScCompiler;
bool ImplGetReference( ScRange& rRange, bool bValidOnly ) const;
+ size_t mnHashValue;
+
public:
ScTokenArray();
/// Assignment with references to ScToken entries (not copied!)
@@ -42,6 +44,7 @@ public:
virtual ~ScTokenArray();
ScTokenArray* Clone() const; /// True copy!
+ void GenHash();
size_t GetHash() const;
/// Exactly and only one range (valid or deleted)
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index b4850ca..07f4673 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3951,6 +3951,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula )
// remember pArr, in case a subsequent CompileTokenArray() is executed.
ScTokenArray* pNew = new ScTokenArray( aArr );
+ pNew->GenHash();
pArr = pNew;
if (!maExternalFiles.empty())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a19f2e3..b595177 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1294,7 +1294,7 @@ size_t HashSingleRef( const ScSingleRefData& rRef )
}
-size_t ScTokenArray::GetHash() const
+void ScTokenArray::GenHash()
{
static OUStringHash aHasher;
@@ -1357,7 +1357,13 @@ size_t ScTokenArray::GetHash() const
// Use the opcode value in all the other cases.
nHash += (static_cast<size_t>(eOp) << i);
}
- return nHash;
+
+ mnHashValue = nHash;
+}
+
+size_t ScTokenArray::GetHash() const
+{
+ return mnHashValue;
}
bool ScTokenArray::IsReference( 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()
{
}
-
-
ScTokenArray& ScTokenArray::operator=( const ScTokenArray& rArr )
{
Clear();
@@ -1402,6 +1410,7 @@ ScTokenArray* ScTokenArray::Clone() const
p->nMode = nMode;
p->nError = nError;
p->bHyperLink = bHyperLink;
+ p->mnHashValue = mnHashValue;
FormulaToken** pp;
if( nLen )
{
More information about the Libreoffice-commits
mailing list