summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-11-04 17:45:25 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-11-05 15:25:45 +0100
commit3ae605f8b93df426236eed359814449589033a79 (patch)
tree38740533bcc77b28334ff15938f65045d7debaf7 /unotools
parentd6765e376706680156e71e985eeeb58bf469f849 (diff)
Replace lists by vectors in configmgr/unotools
+ use for range loops Change-Id: I4cebcf0536dc6c3ddfdce9532e94c0c380ea3ab9 Reviewed-on: https://gerrit.libreoffice.org/44308 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/configmgr.cxx18
-rw-r--r--unotools/source/misc/desktopterminationobserver.cxx30
2 files changed, 12 insertions, 36 deletions
diff --git a/unotools/source/config/configmgr.cxx b/unotools/source/config/configmgr.cxx
index f8b5e891cb02..5dd1dc7ee3f8 100644
--- a/unotools/source/config/configmgr.cxx
+++ b/unotools/source/config/configmgr.cxx
@@ -177,14 +177,7 @@ utl::ConfigManager::addConfigItem(utl::ConfigItem & item) {
}
void utl::ConfigManager::removeConfigItem(utl::ConfigItem & item) {
- for (std::list< ConfigItem * >::iterator i(items_.begin());
- i != items_.end(); ++i)
- {
- if (*i == &item) {
- items_.erase(i);
- break;
- }
- }
+ items_.erase(std::remove(items_.begin(), items_.end(), &item), items_.end());
}
void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
@@ -193,12 +186,11 @@ void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
}
void utl::ConfigManager::doStoreConfigItems() {
- for (std::list< ConfigItem * >::iterator i(items_.begin());
- i != items_.end(); ++i)
+ for (auto const& item : items_)
{
- if ((*i)->IsModified()) {
- (*i)->Commit();
- (*i)->ClearModified();
+ if (item->IsModified()) {
+ item->Commit();
+ item->ClearModified();
}
}
}
diff --git a/unotools/source/misc/desktopterminationobserver.cxx b/unotools/source/misc/desktopterminationobserver.cxx
index 1de3530b917f..2984324caa87 100644
--- a/unotools/source/misc/desktopterminationobserver.cxx
+++ b/unotools/source/misc/desktopterminationobserver.cxx
@@ -26,7 +26,7 @@
#include <comphelper/processfactory.hxx>
#include <osl/diagnose.h>
-#include <list>
+#include <vector>
namespace utl
{
@@ -38,7 +38,7 @@ namespace utl
namespace
{
- typedef ::std::list< ITerminationListener* > Listeners;
+ typedef ::std::vector< ITerminationListener* > Listeners;
struct ListenerAdminData
{
@@ -113,12 +113,9 @@ namespace utl
aToNotify = getListenerAdminData().aListeners;
}
- for ( Listeners::const_iterator listener = aToNotify.begin();
- listener != aToNotify.end();
- ++listener
- )
+ for (auto const& listener : aToNotify)
{
- if ( !(*listener)->queryTermination() )
+ if ( !listener->queryTermination() )
throw TerminationVetoException();
}
}
@@ -135,12 +132,9 @@ namespace utl
}
// notify the listeners
- for ( Listeners::const_iterator listener = aToNotify.begin();
- listener != aToNotify.end();
- ++listener
- )
+ for (auto const& listener : aToNotify)
{
- (*listener)->notifyTermination();
+ listener->notifyTermination();
}
// clear the listener container
@@ -185,17 +179,7 @@ namespace utl
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
Listeners& rListeners = getListenerAdminData().aListeners;
- for ( Listeners::iterator lookup = rListeners.begin();
- lookup != rListeners.end();
- ++lookup
- )
- {
- if ( *lookup == _pListener )
- {
- rListeners.erase( lookup );
- break;
- }
- }
+ rListeners.erase(std::remove(rListeners.begin(), rListeners.end(), _pListener), rListeners.end());
}
} // namespace utl