summaryrefslogtreecommitdiff
path: root/binaryurp
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-11-17 19:05:44 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-18 07:49:45 +0100
commit9d1f61a61893435b26f7239136ad92b7354545a8 (patch)
tree50277f9e2350b222e0624c0df501ec66571fb15d /binaryurp
parent5e69b3619d3a2b05930c5b8b8521d7f2938c709d (diff)
Replace some lists by vectors in binaryurp
+ use for range loops Change-Id: Ied18e378b73826c5a47957cad6cf86a4e19a9230 Reviewed-on: https://gerrit.libreoffice.org/44892 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'binaryurp')
-rw-r--r--binaryurp/source/bridge.cxx27
-rw-r--r--binaryurp/source/bridge.hxx3
-rw-r--r--binaryurp/source/bridgefactory.cxx40
-rw-r--r--binaryurp/source/bridgefactory.hxx8
4 files changed, 38 insertions, 40 deletions
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 4460de1d3c60..92a1665d8a45 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -313,21 +313,23 @@ void Bridge::terminate(bool final) {
osl::MutexGuard g(mutex_);
s.swap(stubs_);
}
- for (Stubs::iterator i(s.begin()); i != s.end(); ++i) {
- for (Stub::iterator j(i->second.begin()); j != i->second.end(); ++j)
+ for (auto & stub : s)
+ {
+ for (auto & item : stub.second)
{
SAL_INFO(
"binaryurp",
- "stub '" << i->first << "', '" << toString(j->first)
+ "stub '" << stub.first << "', '" << toString(item.first)
<< "' still mapped at Bridge::terminate");
binaryUno_.get()->pExtEnv->revokeInterface(
- binaryUno_.get()->pExtEnv, j->second.object.get());
+ binaryUno_.get()->pExtEnv, item.second.object.get());
}
}
factory_->removeBridge(this);
- for (Listeners::iterator i(ls.begin()); i != ls.end(); ++i) {
+ for (auto const& listener : ls)
+ {
try {
- (*i)->disposing(
+ listener->disposing(
css::lang::EventObject(
static_cast< cppu::OWeakObject * >(this)));
} catch (const css::uno::RuntimeException & e) {
@@ -464,11 +466,12 @@ css::uno::UnoInterfaceReference Bridge::findStub(
if (j != i->second.end()) {
return j->second.object;
}
- for (j = i->second.begin(); j != i->second.end(); ++j) {
+ for (auto const& item : i->second)
+ {
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(
css::uno::Reference< css::lang::XEventListener > const & aListener)
{
osl::MutexGuard g(mutex_);
- Listeners::iterator i(
- std::find(listeners_.begin(), listeners_.end(), aListener));
- if (i != listeners_.end()) {
- listeners_.erase(i);
- }
+ listeners_.erase(std::remove(listeners_.begin(), listeners_.end(), aListener), listeners_.end());
}
void Bridge::sendCommitChangeRequest() {
diff --git a/binaryurp/source/bridge.hxx b/binaryurp/source/bridge.hxx
index 476d4af1cf22..a258f331639e 100644
--- a/binaryurp/source/bridge.hxx
+++ b/binaryurp/source/bridge.hxx
@@ -23,7 +23,6 @@
#include <sal/config.h>
#include <cstddef>
-#include <list>
#include <map>
#include <vector>
@@ -221,7 +220,7 @@ private:
void checkDisposed();
typedef
- std::list<
+ std::vector<
com::sun::star::uno::Reference<
com::sun::star::lang::XEventListener > >
Listeners;
diff --git a/binaryurp/source/bridgefactory.cxx b/binaryurp/source/bridgefactory.cxx
index 7da9ccd39aa0..b1e3be93ea74 100644
--- a/binaryurp/source/bridgefactory.cxx
+++ b/binaryurp/source/bridgefactory.cxx
@@ -64,17 +64,15 @@ void BridgeFactory::removeBridge(
assert(bridge.is());
OUString n(bridge->getName());
osl::MutexGuard g(m_aMutex);
- if (n.isEmpty()) {
- BridgeList::iterator i(
- std::find(unnamed_.begin(), unnamed_.end(), bridge));
- if (i != unnamed_.end()) {
- unnamed_.erase(i);
- }
- } else {
+ if (n.isEmpty())
+ {
+ unnamed_.erase(std::remove(unnamed_.begin(), unnamed_.end(), bridge), unnamed_.end());
+ }
+ else
+ {
BridgeMap::iterator i(named_.find(n));
- if (i != named_.end() && i->second == bridge) {
+ if (i != named_.end() && i->second == bridge)
named_.erase(i);
- }
}
}
@@ -161,35 +159,37 @@ BridgeFactory::getExistingBridges() {
n = static_cast< sal_Int32 >(n + named_.size());
css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > s(n);
sal_Int32 i = 0;
- for (BridgeList::iterator j(unnamed_.begin()); j != unnamed_.end(); ++j) {
- s[i++] = *j;
- }
- for (BridgeMap::iterator j(named_.begin()); j != named_.end(); ++j) {
- s[i++] = j->second;
- }
+ for (auto const& item : unnamed_)
+ s[i++] = item;
+
+ for (auto const& item : named_)
+ s[i++] = item.second;
+
return s;
}
void BridgeFactory::disposing() {
- BridgeList l1;
+ BridgeVector l1;
BridgeMap l2;
{
osl::MutexGuard g(m_aMutex);
l1.swap(unnamed_);
l2.swap(named_);
}
- for (BridgeList::iterator i(l1.begin()); i != l1.end(); ++i) {
+ for (auto const& item : l1)
+ {
try {
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) {
SAL_WARN("binaryurp", "ignoring " << e);
}
}
- for (BridgeMap::iterator i(l2.begin()); i != l2.end(); ++i) {
+ for (auto const& item : l2)
+ {
try {
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) {
SAL_WARN("binaryurp", "ignoring " << e);
}
diff --git a/binaryurp/source/bridgefactory.hxx b/binaryurp/source/bridgefactory.hxx
index a08016932200..048cbb8deeaf 100644
--- a/binaryurp/source/bridgefactory.hxx
+++ b/binaryurp/source/bridgefactory.hxx
@@ -23,7 +23,7 @@
#include <sal/config.h>
#include <exception>
-#include <list>
+#include <vector>
#include <map>
#include <com/sun/star/bridge/XBridgeFactory2.hpp>
@@ -110,9 +110,9 @@ private:
void SAL_CALL disposing() override;
typedef
- std::list<
+ std::vector<
com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
- BridgeList;
+ BridgeVector;
typedef
std::map<
@@ -120,7 +120,7 @@ private:
com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
BridgeMap;
- BridgeList unnamed_;
+ BridgeVector unnamed_;
BridgeMap named_;
};