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>
This commit is contained in:
parent
d6765e3767
commit
3ae605f8b9
4 changed files with 15 additions and 40 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue