[Libreoffice-commits] .: sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Jun 6 13:47:07 PDT 2012
sc/inc/queryparam.hxx | 10 +++++++++-
sc/source/core/data/table3.cxx | 8 ++++----
sc/source/core/tool/queryparam.cxx | 10 ++++++++++
3 files changed, 23 insertions(+), 5 deletions(-)
New commits:
commit 237e4f52abefc3714accef79deae976f634e04ec
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jun 6 16:46:03 2012 -0400
Use iterators over index access.
This makes ValidQuery *slightly* faster.
Change-Id: I9fff6099b597d7a8d4d5a4358099348baa657802
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 77108ab..27d121c 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 4e7e874..85354f3 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 b814b27..e6059ab 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),
More information about the Libreoffice-commits
mailing list