diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2018-12-13 10:46:28 +0900 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-13 07:32:21 +0100 |
commit | 320a77a3145b4eb9092c4379d4b5b999bd14901f (patch) | |
tree | a245ceb0639d7476a7e4189be201b41781e19512 /sc | |
parent | e98bcfcc3cdad46620e3d59119b0ac262db88054 (diff) |
sc: Use std::find() to simplify code
Change-Id: I903a59591cd204556e873429280aac9cf8d5325a
Reviewed-on: https://gerrit.libreoffice.org/65067
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/dociter.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/dpdimsave.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/data/dpfilteredcache.cxx | 10 |
3 files changed, 10 insertions, 21 deletions
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 02ae04ccbc81..720bd573b0d0 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -44,6 +44,7 @@ #include <svl/sharedstring.hxx> #include <unotools/collatorwrapper.hxx> +#include <algorithm> #include <vector> using ::rtl::math::approxEqual; @@ -732,12 +733,7 @@ bool ScDBQueryDataIterator::DataAccessMatrix::isValidQuery(SCROW nRow, const ScM } // Row is valid as long as there is at least one result being true. - vector<bool>::const_iterator itr = aResults.begin(), itrEnd = aResults.end(); - for (; itr != itrEnd; ++itr) - if (*itr) - return true; - - return false; + return std::find(aResults.begin(), aResults.end(), true) != aResults.end(); } ScDBQueryDataIterator::Value::Value() : diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx index 2319294b49c5..f2f87aa668e1 100644 --- a/sc/source/core/data/dpdimsave.cxx +++ b/sc/source/core/data/dpdimsave.cxx @@ -57,13 +57,12 @@ void ScDPSaveGroupItem::AddElementsFromGroup( const ScDPSaveGroupItem& rGroup ) bool ScDPSaveGroupItem::RemoveElement( const OUString& rName ) { - for (std::vector<OUString>::iterator aIter = aElements.begin(); aIter != aElements.end(); ++aIter) - if (*aIter == rName) //TODO: ignore case - { - aElements.erase(aIter); // found -> remove - return true; // don't have to look further - } - + auto it = std::find(aElements.begin(), aElements.end(), rName); //TODO: ignore case + if (it != aElements.end()) + { + aElements.erase(it); + return true; + } return false; // not found } diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx index e3f47ffd7fcb..f46c6cd96065 100644 --- a/sc/source/core/data/dpfilteredcache.cxx +++ b/sc/source/core/data/dpfilteredcache.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <osl/diagnose.h> +#include <algorithm> using ::std::vector; using ::com::sun::star::uno::Sequence; @@ -51,14 +52,7 @@ ScDPFilteredCache::GroupFilter::GroupFilter() bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const { - vector<ScDPItemData>::const_iterator it = maItems.begin(), itEnd = maItems.end(); - for (; it != itEnd; ++it) - { - bool bMatch = *it == rCellData; - if (bMatch) - return true; - } - return false; + return std::find(maItems.begin(), maItems.end(), rCellData) != maItems.end(); } std::vector<ScDPItemData> ScDPFilteredCache::GroupFilter::getMatchValues() const |