diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-03-03 13:10:45 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-03 16:27:08 +0100 |
commit | 5af9e26ae8b463e85cb84f79a366c61d49a2d52b (patch) | |
tree | d8e001ed45e2a441e19864f8e2613317c9019ffa /cppuhelper/source/weak.cxx | |
parent | 20b1a4589ee95e34afdb3c82834fe32e1ccb25fb (diff) |
Simplify containers iterations in cppcanvas, cppu, cppuhelper
Use range-based loop or replace with STL functions
Change-Id: I72bf7cdb632c04e2fc8d4f7ab85cb6571222aa07
Reviewed-on: https://gerrit.libreoffice.org/68636
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppuhelper/source/weak.cxx')
-rw-r--r-- | cppuhelper/source/weak.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index 57f22880adfc..cfb455f54488 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -183,14 +183,14 @@ void SAL_CALL OWeakConnectionPoint::removeReference(const Reference< XReference // Search from end because the thing that last added a ref is most likely to be the // first to remove a ref. // It's not really valid to compare the pointer directly, but it's faster. - for (auto it = m_aReferences.rbegin(); it != m_aReferences.rend(); ++it) { - if (it->get() == rRef.get()) { - m_aReferences.erase( it.base()-1 ); - return; - } + auto it = std::find_if(m_aReferences.rbegin(), m_aReferences.rend(), + [&rRef](const Reference<XReference>& rxRef) { return rxRef.get() == rRef.get(); }); + if (it != m_aReferences.rend()) { + m_aReferences.erase( it.base()-1 ); + return; } // interface not found, use the correct compare method - auto it = std::find(m_aReferences.rbegin(), m_aReferences.rend(), rRef); + it = std::find(m_aReferences.rbegin(), m_aReferences.rend(), rRef); if ( it != m_aReferences.rend() ) m_aReferences.erase( it.base()-1 ); } |