summaryrefslogtreecommitdiff
path: root/sax/test
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-12 00:00:22 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-12 07:37:08 +0100
commit3f08be2e511dc2300021486a1cc2f1e8ba530373 (patch)
tree4498ff04e82aa36b94274af254b60f35e29805a8 /sax/test
parentf9c57cae202818258b416b4ca28040a44e8887c2 (diff)
Simplify containers iterations in reportdesign, sal, sax
Use range-based loop or replace with STL functions Change-Id: If6b734dab12a7298fce16003d3d175305fbe798d Reviewed-on: https://gerrit.libreoffice.org/67701 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax/test')
-rw-r--r--sax/test/sax/testwriter.cxx26
-rw-r--r--sax/test/saxdemo.cxx22
2 files changed, 16 insertions, 32 deletions
diff --git a/sax/test/sax/testwriter.cxx b/sax/test/sax/testwriter.cxx
index ee323ef5cf77..505e3d8a410f 100644
--- a/sax/test/sax/testwriter.cxx
+++ b/sax/test/sax/testwriter.cxx
@@ -236,29 +236,19 @@ OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeExceptio
OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for (; ii != m_pImpl->vecAttribute.end(); ++ii)
- {
- if( (*ii).sName == sName )
- {
- return (*ii).sType;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sType;
return OUString();
}
OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for(; ii != m_pImpl->vecAttribute.end(); ++ii)
- {
- if( (*ii).sName == sName )
- {
- return (*ii).sValue;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sValue;
return OUString();
}
diff --git a/sax/test/saxdemo.cxx b/sax/test/saxdemo.cxx
index f00d598b722f..a501294529e1 100644
--- a/sax/test/saxdemo.cxx
+++ b/sax/test/saxdemo.cxx
@@ -343,25 +343,19 @@ OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeExceptio
OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
- if( (*ii).sName == sName ) {
- return (*ii).sType;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sType;
return OUString();
}
OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
- if( (*ii).sName == sName ) {
- return (*ii).sValue;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sValue;
return OUString();
}