summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-06-06 14:49:22 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-06-06 15:35:33 -0400
commit633178bffaf23ae322060e2c304c9c2cf12b46cc (patch)
treee248b4f6301d9c265e1fd7f67862064fb14010d7 /sc
parent3be5d6bfe2c4934fffb93e3b2b81256fc62e2138 (diff)
Avoid expensive allocation & deallocation of local vector on every call.
This alone reduces the ValidQuery() call by 70%. Change-Id: Ic9f8adbd0cb63297be7e173c39e4bcf886d1e2d2
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table3.cxx27
1 files changed, 13 insertions, 14 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 7e766a37293a..4e7e874ed201 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1521,11 +1521,12 @@ bool ScTable::ValidQuery(
if (!rParam.GetEntry(0).bDoQuery)
return true;
- //---------------------------------------------------------------
-
SCSIZE nEntryCount = rParam.GetEntryCount();
- std::vector<bool> aPassed(nEntryCount, false);
- std::vector<bool> aTestEqual(nEntryCount, false);
+
+ typedef std::pair<bool,bool> ResultType;
+ static std::vector<ResultType> aResults;
+ if (aResults.size() < nEntryCount)
+ aResults.resize(nEntryCount);
long nPos = -1;
QueryEvaluator aEval(*pDocument, *this, rParam, pbTestEqualCondition);
@@ -1581,34 +1582,32 @@ bool ScTable::ValidQuery(
if (nPos == -1)
{
nPos++;
- aPassed[nPos] = aRes.first;
- aTestEqual[nPos] = aRes.second;
+ aResults[nPos] = aRes;
}
else
{
if (rEntry.eConnect == SC_AND)
{
- aPassed[nPos] = aPassed[nPos] && aRes.first;
- aTestEqual[nPos] = aTestEqual[nPos] && aRes.second;
+ aResults[nPos].first = aResults[nPos].first && aRes.first;
+ aResults[nPos].second = aResults[nPos].second && aRes.second;
}
else
{
nPos++;
- aPassed[nPos] = aRes.first;
- aTestEqual[nPos] = aRes.second;
+ aResults[nPos] = aRes;
}
}
}
for ( long j=1; j <= nPos; j++ )
{
- aPassed[0] = aPassed[0] || aPassed[j];
- aTestEqual[0] = aTestEqual[0] || aTestEqual[j];
+ aResults[0].first = aResults[0].first || aResults[j].first;
+ aResults[0].second = aResults[0].second || aResults[j].second;
}
- bool bRet = aPassed[0];
+ bool bRet = aResults[0].first;
if ( pbTestEqualCondition )
- *pbTestEqualCondition = aTestEqual[0];
+ *pbTestEqualCondition = aResults[0].second;
return bRet;
}