summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-16 18:39:23 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-18 07:41:05 +0100
commit44841a6778821be3e68ab15819b39064b20e968f (patch)
tree8e9119cf35764f18f5b008e7758c6f950306fb8c /forms
parentbcfbd24be02d2de5d4d27c147dc58c4515a9a0f5 (diff)
Simplify containers iterations in [f-l]*
Use range-based loop or replace with STL functions Change-Id: Ib3fab47318d1bfbb4df8f886a8cd9596525a420f Reviewed-on: https://gerrit.libreoffice.org/67914 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/EventThread.cxx8
-rw-r--r--forms/source/misc/InterfaceContainer.cxx13
-rw-r--r--forms/source/xforms/namedcollection.hxx19
3 files changed, 15 insertions, 25 deletions
diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx
index 76022a84f62d..a44349e36bc1 100644
--- a/forms/source/component/EventThread.cxx
+++ b/forms/source/component/EventThread.cxx
@@ -71,11 +71,9 @@ Any SAL_CALL OComponentEventThread::queryInterface(const Type& _rType)
void OComponentEventThread::impl_clearEventQueue()
{
- while ( !m_aEvents.empty() )
- {
- delete *m_aEvents.begin();
- m_aEvents.erase( m_aEvents.begin() );
- }
+ for ( auto& rEvent : m_aEvents )
+ delete rEvent;
+ m_aEvents.clear();
m_aControls.erase( m_aControls.begin(), m_aControls.end() );
m_aFlags.erase( m_aFlags.begin(), m_aFlags.end() );
}
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index eefe6b5dc552..dd65163908e9 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -866,8 +866,8 @@ void OInterfaceContainer::removeElementsNoEvents()
OInterfaceArray::iterator i = m_aItems.begin();
css::uno::Reference<css::uno::XInterface> xElement(*i);
- OInterfaceMap::iterator j = m_aMap.begin();
- while (j != m_aMap.end() && (*j).second != xElement) ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
m_aItems.erase(i);
m_aMap.erase(j);
@@ -930,9 +930,8 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any
"OInterfaceContainer::implReplaceByIndex: elements should be held normalized!" );
// locate the old element in the map
- OInterfaceMap::iterator j = m_aMap.begin();
- while ( ( j != m_aMap.end() ) && ( j->second.get() != xOldElement.get() ) )
- ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xOldElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second.get() == xOldElement.get(); });
// remove event knittings
if ( m_xEventAttacher.is() )
@@ -1011,8 +1010,8 @@ void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::Cle
OInterfaceArray::iterator i = m_aItems.begin() + _nIndex;
css::uno::Reference<css::uno::XInterface> xElement(*i);
- OInterfaceMap::iterator j = m_aMap.begin();
- while (j != m_aMap.end() && (*j).second != xElement) ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
m_aItems.erase(i);
m_aMap.erase(j);
diff --git a/forms/source/xforms/namedcollection.hxx b/forms/source/xforms/namedcollection.hxx
index a9931eb97c3d..72c8b36e68a2 100644
--- a/forms/source/xforms/namedcollection.hxx
+++ b/forms/source/xforms/namedcollection.hxx
@@ -53,12 +53,10 @@ public:
{
// iterate over members, and collect all those that have names
std::vector<OUString> aNames;
- for( typename std::vector<T>::const_iterator aIter = maItems.begin();
- aIter != maItems.end();
- ++aIter )
+ for( const T& rItem : maItems )
{
css::uno::Reference<css::container::XNamed>
- xNamed( *aIter, css::uno::UNO_QUERY );
+ xNamed( rItem, css::uno::UNO_QUERY );
if( xNamed.is() )
aNames.push_back( xNamed->getName() );
}
@@ -69,16 +67,11 @@ public:
protected:
typename std::vector<T>::const_iterator findItem( const OUString& rName ) const
{
- for( typename std::vector<T>::const_iterator aIter = maItems.begin();
- aIter != maItems.end();
- ++aIter )
- {
+ return std::find_if(maItems.begin(), maItems.end(), [&rName](const T& rItem) {
css::uno::Reference<css::container::XNamed>
- xNamed( *aIter, css::uno::UNO_QUERY );
- if( xNamed.is() && xNamed->getName() == rName )
- return aIter;
- }
- return maItems.end();
+ xNamed( rItem, css::uno::UNO_QUERY );
+ return xNamed.is() && xNamed->getName() == rName;
+ });
}
public: