summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-06-06 16:46:03 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-06-06 16:48:17 -0400
commit95626fddef8a9ca5987b49c410f7f1374250a4a1 (patch)
tree5ec5ec2b2944371ac690ed156c66a145fd2f2d09
parent8bb328c1d77cebf7fbd27e00467d1f722d130778 (diff)
Use iterators over index access.
This makes ValidQuery *slightly* faster. Change-Id: I9fff6099b597d7a8d4d5a4358099348baa657802
-rw-r--r--sc/inc/queryparam.hxx10
-rw-r--r--sc/source/core/data/table3.cxx8
-rw-r--r--sc/source/core/tool/queryparam.cxx10
3 files changed, 23 insertions, 5 deletions
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 77108abe97b5..27d121c19443 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -60,10 +60,18 @@ struct ScQueryParamBase
void FillInExcelSyntax(const rtl::OUString& aCellStr, SCSIZE nIndex);
protected:
+ typedef boost::ptr_vector<ScQueryEntry> EntriesType;
+
+public:
+ typedef EntriesType::const_iterator const_iterator;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+protected:
ScQueryParamBase();
ScQueryParamBase(const ScQueryParamBase& r);
- typedef boost::ptr_vector<ScQueryEntry> EntriesType;
EntriesType maEntries;
};
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 4e7e874ed201..85354f3bb27d 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1530,14 +1530,14 @@ bool ScTable::ValidQuery(
long nPos = -1;
QueryEvaluator aEval(*pDocument, *this, rParam, pbTestEqualCondition);
-
- for (size_t i = 0; i < nEntryCount && rParam.GetEntry(i).bDoQuery; ++i)
+ ScQueryParam::const_iterator it, itBeg = rParam.begin(), itEnd = rParam.end();
+ for (it = itBeg; it != itEnd && it->bDoQuery; ++it)
{
- const ScQueryEntry& rEntry = rParam.GetEntry(i);
+ const ScQueryEntry& rEntry = *it;
SCCOL nCol = static_cast<SCCOL>(rEntry.nField);
// we can only handle one single direct query
- if ( !pCell || i > 0 )
+ if (!pCell || it != itBeg)
pCell = GetCell(nCol, nRow);
std::pair<bool,bool> aRes(false, false);
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index b814b2788c42..e6059ab1ac9c 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -57,6 +57,16 @@ struct FindUnused : public std::unary_function<ScQueryEntry, bool>
}
+ScQueryParamBase::const_iterator ScQueryParamBase::begin() const
+{
+ return maEntries.begin();
+}
+
+ScQueryParamBase::const_iterator ScQueryParamBase::end() const
+{
+ return maEntries.end();
+}
+
ScQueryParamBase::ScQueryParamBase() :
bHasHeader(true),
bByRow(true),