Kaydet (Commit) 320a77a3 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

sc: Use std::find() to simplify code

Change-Id: I903a59591cd204556e873429280aac9cf8d5325a
Reviewed-on: https://gerrit.libreoffice.org/65067
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e98bcfcc
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <svl/sharedstring.hxx> #include <svl/sharedstring.hxx>
#include <unotools/collatorwrapper.hxx> #include <unotools/collatorwrapper.hxx>
#include <algorithm>
#include <vector> #include <vector>
using ::rtl::math::approxEqual; using ::rtl::math::approxEqual;
...@@ -732,12 +733,7 @@ bool ScDBQueryDataIterator::DataAccessMatrix::isValidQuery(SCROW nRow, const ScM ...@@ -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. // Row is valid as long as there is at least one result being true.
vector<bool>::const_iterator itr = aResults.begin(), itrEnd = aResults.end(); return std::find(aResults.begin(), aResults.end(), true) != aResults.end();
for (; itr != itrEnd; ++itr)
if (*itr)
return true;
return false;
} }
ScDBQueryDataIterator::Value::Value() : ScDBQueryDataIterator::Value::Value() :
......
...@@ -57,13 +57,12 @@ void ScDPSaveGroupItem::AddElementsFromGroup( const ScDPSaveGroupItem& rGroup ) ...@@ -57,13 +57,12 @@ void ScDPSaveGroupItem::AddElementsFromGroup( const ScDPSaveGroupItem& rGroup )
bool ScDPSaveGroupItem::RemoveElement( const OUString& rName ) bool ScDPSaveGroupItem::RemoveElement( const OUString& rName )
{ {
for (std::vector<OUString>::iterator aIter = aElements.begin(); aIter != aElements.end(); ++aIter) auto it = std::find(aElements.begin(), aElements.end(), rName); //TODO: ignore case
if (*aIter == rName) //TODO: ignore case if (it != aElements.end())
{ {
aElements.erase(aIter); // found -> remove aElements.erase(it);
return true; // don't have to look further return true;
} }
return false; // not found return false; // not found
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <algorithm>
using ::std::vector; using ::std::vector;
using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Sequence;
...@@ -51,14 +52,7 @@ ScDPFilteredCache::GroupFilter::GroupFilter() ...@@ -51,14 +52,7 @@ ScDPFilteredCache::GroupFilter::GroupFilter()
bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const
{ {
vector<ScDPItemData>::const_iterator it = maItems.begin(), itEnd = maItems.end(); return std::find(maItems.begin(), maItems.end(), rCellData) != maItems.end();
for (; it != itEnd; ++it)
{
bool bMatch = *it == rCellData;
if (bMatch)
return true;
}
return false;
} }
std::vector<ScDPItemData> ScDPFilteredCache::GroupFilter::getMatchValues() const std::vector<ScDPItemData> ScDPFilteredCache::GroupFilter::getMatchValues() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment