Kaydet (Commit) 9d1f61a6 authored tarafından Julien Nabet's avatar Julien Nabet Kaydeden (comit) Noel Grandin

Replace some lists by vectors in binaryurp

+ use for range loops

Change-Id: Ied18e378b73826c5a47957cad6cf86a4e19a9230
Reviewed-on: https://gerrit.libreoffice.org/44892Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5e69b361
...@@ -313,21 +313,23 @@ void Bridge::terminate(bool final) { ...@@ -313,21 +313,23 @@ void Bridge::terminate(bool final) {
osl::MutexGuard g(mutex_); osl::MutexGuard g(mutex_);
s.swap(stubs_); s.swap(stubs_);
} }
for (Stubs::iterator i(s.begin()); i != s.end(); ++i) { for (auto & stub : s)
for (Stub::iterator j(i->second.begin()); j != i->second.end(); ++j) {
for (auto & item : stub.second)
{ {
SAL_INFO( SAL_INFO(
"binaryurp", "binaryurp",
"stub '" << i->first << "', '" << toString(j->first) "stub '" << stub.first << "', '" << toString(item.first)
<< "' still mapped at Bridge::terminate"); << "' still mapped at Bridge::terminate");
binaryUno_.get()->pExtEnv->revokeInterface( binaryUno_.get()->pExtEnv->revokeInterface(
binaryUno_.get()->pExtEnv, j->second.object.get()); binaryUno_.get()->pExtEnv, item.second.object.get());
} }
} }
factory_->removeBridge(this); factory_->removeBridge(this);
for (Listeners::iterator i(ls.begin()); i != ls.end(); ++i) { for (auto const& listener : ls)
{
try { try {
(*i)->disposing( listener->disposing(
css::lang::EventObject( css::lang::EventObject(
static_cast< cppu::OWeakObject * >(this))); static_cast< cppu::OWeakObject * >(this)));
} catch (const css::uno::RuntimeException & e) { } catch (const css::uno::RuntimeException & e) {
...@@ -464,11 +466,12 @@ css::uno::UnoInterfaceReference Bridge::findStub( ...@@ -464,11 +466,12 @@ css::uno::UnoInterfaceReference Bridge::findStub(
if (j != i->second.end()) { if (j != i->second.end()) {
return j->second.object; return j->second.object;
} }
for (j = i->second.begin(); j != i->second.end(); ++j) { for (auto const& item : i->second)
{
if (typelib_typedescription_isAssignableFrom( if (typelib_typedescription_isAssignableFrom(
type.get(), j->first.get())) type.get(), item.first.get()))
{ {
return j->second.object; return item.second.object;
} }
} }
} }
...@@ -924,11 +927,7 @@ void Bridge::removeEventListener( ...@@ -924,11 +927,7 @@ void Bridge::removeEventListener(
css::uno::Reference< css::lang::XEventListener > const & aListener) css::uno::Reference< css::lang::XEventListener > const & aListener)
{ {
osl::MutexGuard g(mutex_); osl::MutexGuard g(mutex_);
Listeners::iterator i( listeners_.erase(std::remove(listeners_.begin(), listeners_.end(), aListener), listeners_.end());
std::find(listeners_.begin(), listeners_.end(), aListener));
if (i != listeners_.end()) {
listeners_.erase(i);
}
} }
void Bridge::sendCommitChangeRequest() { void Bridge::sendCommitChangeRequest() {
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <sal/config.h> #include <sal/config.h>
#include <cstddef> #include <cstddef>
#include <list>
#include <map> #include <map>
#include <vector> #include <vector>
...@@ -221,7 +220,7 @@ private: ...@@ -221,7 +220,7 @@ private:
void checkDisposed(); void checkDisposed();
typedef typedef
std::list< std::vector<
com::sun::star::uno::Reference< com::sun::star::uno::Reference<
com::sun::star::lang::XEventListener > > com::sun::star::lang::XEventListener > >
Listeners; Listeners;
......
...@@ -64,17 +64,15 @@ void BridgeFactory::removeBridge( ...@@ -64,17 +64,15 @@ void BridgeFactory::removeBridge(
assert(bridge.is()); assert(bridge.is());
OUString n(bridge->getName()); OUString n(bridge->getName());
osl::MutexGuard g(m_aMutex); osl::MutexGuard g(m_aMutex);
if (n.isEmpty()) { if (n.isEmpty())
BridgeList::iterator i( {
std::find(unnamed_.begin(), unnamed_.end(), bridge)); unnamed_.erase(std::remove(unnamed_.begin(), unnamed_.end(), bridge), unnamed_.end());
if (i != unnamed_.end()) { }
unnamed_.erase(i); else
} {
} else {
BridgeMap::iterator i(named_.find(n)); BridgeMap::iterator i(named_.find(n));
if (i != named_.end() && i->second == bridge) { if (i != named_.end() && i->second == bridge)
named_.erase(i); named_.erase(i);
}
} }
} }
...@@ -161,35 +159,37 @@ BridgeFactory::getExistingBridges() { ...@@ -161,35 +159,37 @@ BridgeFactory::getExistingBridges() {
n = static_cast< sal_Int32 >(n + named_.size()); n = static_cast< sal_Int32 >(n + named_.size());
css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > s(n); css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > s(n);
sal_Int32 i = 0; sal_Int32 i = 0;
for (BridgeList::iterator j(unnamed_.begin()); j != unnamed_.end(); ++j) { for (auto const& item : unnamed_)
s[i++] = *j; s[i++] = item;
}
for (BridgeMap::iterator j(named_.begin()); j != named_.end(); ++j) { for (auto const& item : named_)
s[i++] = j->second; s[i++] = item.second;
}
return s; return s;
} }
void BridgeFactory::disposing() { void BridgeFactory::disposing() {
BridgeList l1; BridgeVector l1;
BridgeMap l2; BridgeMap l2;
{ {
osl::MutexGuard g(m_aMutex); osl::MutexGuard g(m_aMutex);
l1.swap(unnamed_); l1.swap(unnamed_);
l2.swap(named_); l2.swap(named_);
} }
for (BridgeList::iterator i(l1.begin()); i != l1.end(); ++i) { for (auto const& item : l1)
{
try { try {
css::uno::Reference<css::lang::XComponent>( css::uno::Reference<css::lang::XComponent>(
*i, css::uno::UNO_QUERY_THROW)->dispose(); item, css::uno::UNO_QUERY_THROW)->dispose();
} catch (css::uno::Exception & e) { } catch (css::uno::Exception & e) {
SAL_WARN("binaryurp", "ignoring " << e); SAL_WARN("binaryurp", "ignoring " << e);
} }
} }
for (BridgeMap::iterator i(l2.begin()); i != l2.end(); ++i) { for (auto const& item : l2)
{
try { try {
css::uno::Reference<css::lang::XComponent>( css::uno::Reference<css::lang::XComponent>(
i->second, css::uno::UNO_QUERY_THROW)->dispose(); item.second, css::uno::UNO_QUERY_THROW)->dispose();
} catch (css::uno::Exception & e) { } catch (css::uno::Exception & e) {
SAL_WARN("binaryurp", "ignoring " << e); SAL_WARN("binaryurp", "ignoring " << e);
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <sal/config.h> #include <sal/config.h>
#include <exception> #include <exception>
#include <list> #include <vector>
#include <map> #include <map>
#include <com/sun/star/bridge/XBridgeFactory2.hpp> #include <com/sun/star/bridge/XBridgeFactory2.hpp>
...@@ -110,9 +110,9 @@ private: ...@@ -110,9 +110,9 @@ private:
void SAL_CALL disposing() override; void SAL_CALL disposing() override;
typedef typedef
std::list< std::vector<
com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
BridgeList; BridgeVector;
typedef typedef
std::map< std::map<
...@@ -120,7 +120,7 @@ private: ...@@ -120,7 +120,7 @@ private:
com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
BridgeMap; BridgeMap;
BridgeList unnamed_; BridgeVector unnamed_;
BridgeMap named_; BridgeMap named_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment