diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-11-04 17:45:25 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-11-05 15:25:45 +0100 |
commit | 3ae605f8b93df426236eed359814449589033a79 (patch) | |
tree | 38740533bcc77b28334ff15938f65045d7debaf7 | |
parent | d6765e376706680156e71e985eeeb58bf469f849 (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>
-rw-r--r-- | configmgr/source/additions.hxx | 3 | ||||
-rw-r--r-- | include/unotools/configmgr.hxx | 4 | ||||
-rw-r--r-- | unotools/source/config/configmgr.cxx | 18 | ||||
-rw-r--r-- | unotools/source/misc/desktopterminationobserver.cxx | 30 |
4 files changed, 15 insertions, 40 deletions
diff --git a/configmgr/source/additions.hxx b/configmgr/source/additions.hxx index 1bc779e2fcea..d7394411b1e0 100644 --- a/configmgr/source/additions.hxx +++ b/configmgr/source/additions.hxx @@ -22,12 +22,11 @@ #include <sal/config.h> -#include <list> #include <vector> namespace configmgr { // Additions is a list of configuration node paths -typedef std::list< std::vector<OUString> > Additions; +typedef std::vector< std::vector<OUString> > Additions; } diff --git a/include/unotools/configmgr.hxx b/include/unotools/configmgr.hxx index c74305b3c6b1..fe6a13545ed0 100644 --- a/include/unotools/configmgr.hxx +++ b/include/unotools/configmgr.hxx @@ -22,7 +22,7 @@ #include <sal/config.h> -#include <list> +#include <vector> #include <com/sun/star/uno/Reference.hxx> #include <sal/types.h> @@ -84,7 +84,7 @@ private: void doStoreConfigItems(); - std::list< ConfigItem * > items_; + std::vector< ConfigItem * > items_; }; } 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 |