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 <sal/config.h>
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace configmgr {
|
namespace configmgr {
|
||||||
// Additions is a list of configuration node paths
|
// 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 <sal/config.h>
|
||||||
|
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
#include <com/sun/star/uno/Reference.hxx>
|
#include <com/sun/star/uno/Reference.hxx>
|
||||||
#include <sal/types.h>
|
#include <sal/types.h>
|
||||||
|
@ -84,7 +84,7 @@ private:
|
||||||
|
|
||||||
void doStoreConfigItems();
|
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) {
|
void utl::ConfigManager::removeConfigItem(utl::ConfigItem & item) {
|
||||||
for (std::list< ConfigItem * >::iterator i(items_.begin());
|
items_.erase(std::remove(items_.begin(), items_.end(), &item), items_.end());
|
||||||
i != items_.end(); ++i)
|
|
||||||
{
|
|
||||||
if (*i == &item) {
|
|
||||||
items_.erase(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
|
void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
|
||||||
|
@ -193,12 +186,11 @@ void utl::ConfigManager::registerConfigItem(utl::ConfigItem * item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void utl::ConfigManager::doStoreConfigItems() {
|
void utl::ConfigManager::doStoreConfigItems() {
|
||||||
for (std::list< ConfigItem * >::iterator i(items_.begin());
|
for (auto const& item : items_)
|
||||||
i != items_.end(); ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->IsModified()) {
|
if (item->IsModified()) {
|
||||||
(*i)->Commit();
|
item->Commit();
|
||||||
(*i)->ClearModified();
|
item->ClearModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
#include <osl/diagnose.h>
|
#include <osl/diagnose.h>
|
||||||
|
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
namespace utl
|
namespace utl
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace utl
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef ::std::list< ITerminationListener* > Listeners;
|
typedef ::std::vector< ITerminationListener* > Listeners;
|
||||||
|
|
||||||
struct ListenerAdminData
|
struct ListenerAdminData
|
||||||
{
|
{
|
||||||
|
@ -113,12 +113,9 @@ namespace utl
|
||||||
aToNotify = getListenerAdminData().aListeners;
|
aToNotify = getListenerAdminData().aListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Listeners::const_iterator listener = aToNotify.begin();
|
for (auto const& listener : aToNotify)
|
||||||
listener != aToNotify.end();
|
|
||||||
++listener
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if ( !(*listener)->queryTermination() )
|
if ( !listener->queryTermination() )
|
||||||
throw TerminationVetoException();
|
throw TerminationVetoException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,12 +132,9 @@ namespace utl
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify the listeners
|
// notify the listeners
|
||||||
for ( Listeners::const_iterator listener = aToNotify.begin();
|
for (auto const& listener : aToNotify)
|
||||||
listener != aToNotify.end();
|
|
||||||
++listener
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
(*listener)->notifyTermination();
|
listener->notifyTermination();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the listener container
|
// clear the listener container
|
||||||
|
@ -185,17 +179,7 @@ namespace utl
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
||||||
Listeners& rListeners = getListenerAdminData().aListeners;
|
Listeners& rListeners = getListenerAdminData().aListeners;
|
||||||
for ( Listeners::iterator lookup = rListeners.begin();
|
rListeners.erase(std::remove(rListeners.begin(), rListeners.end(), _pListener), rListeners.end());
|
||||||
lookup != rListeners.end();
|
|
||||||
++lookup
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if ( *lookup == _pListener )
|
|
||||||
{
|
|
||||||
rListeners.erase( lookup );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace utl
|
} // namespace utl
|
||||||
|
|
Loading…
Reference in a new issue