summaryrefslogtreecommitdiff
path: root/unodevtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-18 15:13:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-19 13:19:31 +0200
commit1a5b12aa5da2c718848d3cc5d9bce7bfcdeacf54 (patch)
tree25044edc2afb99073ba6bef8d181dadbb6a53467 /unodevtools
parenteaaaad0e21edb27edaa865eee03696f007cd8010 (diff)
optimise find/insert pattern
if we're doing a find/insert on a set or a map, it is better to just do a conditional insert/emplace operation than triggering two lookups. Change-Id: I80da5097f5a89fe30fa348ce5b6e747c34287a8d Reviewed-on: https://gerrit.libreoffice.org/70937 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unodevtools')
-rw-r--r--unodevtools/source/skeletonmaker/cppcompskeleton.cxx4
-rw-r--r--unodevtools/source/skeletonmaker/javacompskeleton.cxx4
-rw-r--r--unodevtools/source/skeletonmaker/skeletoncommon.cxx20
3 files changed, 8 insertions, 20 deletions
diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
index 097115d94879..c1fec780e9ff 100644
--- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
@@ -1101,9 +1101,7 @@ void generateCalcAddin(ProgramOptions const & options,
// special case for the optional XLocalization interface. It should be
// implemented always. But it is parent of the XAddIn and we need it only
// if backwardcompatible is false.
- if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) {
- interfaces.insert("com.sun.star.lang.XLocalizable");
- }
+ interfaces.insert("com.sun.star.lang.XLocalizable");
}
OUString propertyhelper = checkPropertyHelper(
diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index 741387cfe120..04cd31cb22a3 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -845,9 +845,7 @@ void generateSkeleton(ProgramOptions const & options,
// special case for the optional XLocalization interface. It should be
// implemented always. But it is parent of the XAddIn and we need it only
// if backwardcompatible is false.
- if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) {
- interfaces.insert("com.sun.star.lang.XLocalizable");
- }
+ interfaces.insert("com.sun.star.lang.XLocalizable");
}
}
diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
index f57afcdab7ce..37041a8be951 100644
--- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx
+++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
@@ -183,19 +183,15 @@ void checkType(rtl::Reference< TypeManager > const & manager,
if ( name == "com.sun.star.lang.XTypeProvider" ||
name == "com.sun.star.uno.XWeak" )
return;
- if (interfaceTypes.find(name) == interfaceTypes.end()) {
- interfaceTypes.insert(name);
- }
+ interfaceTypes.insert(name);
break;
case codemaker::UnoType::Sort::SingleInterfaceBasedService:
- if (serviceTypes.find(name) == serviceTypes.end()) {
- serviceTypes.insert(name);
+ if (serviceTypes.insert(name).second) {
rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
ent.get()));
assert(ent2.is());
- if (interfaceTypes.find(ent2->getBase()) == interfaceTypes.end()) {
- interfaceTypes.insert(ent2->getBase());
+ if (interfaceTypes.insert(ent2->getBase()).second) {
// check if constructors are specified, if yes automatically
// support of XInitialization. We will take care of the default
// constructor because in this case XInitialization is not
@@ -204,16 +200,13 @@ void checkType(rtl::Reference< TypeManager > const & manager,
(ent2->getConstructors().size() == 1 &&
!ent2->getConstructors()[0].defaultConstructor))
{
- OUString s("com.sun.star.lang.XInitialization");
- if (interfaceTypes.find(s) == interfaceTypes.end())
- interfaceTypes.insert(s);
+ interfaceTypes.insert(OUString("com.sun.star.lang.XInitialization"));
}
}
}
break;
case codemaker::UnoType::Sort::AccumulationBasedService:
- if ( serviceTypes.find(name) == serviceTypes.end() ) {
- serviceTypes.insert(name);
+ if ( serviceTypes.insert(name).second ) {
rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2(
dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
ent.get()));
@@ -249,8 +242,7 @@ void checkDefaultInterfaces(
if ( services.empty() ) {
interfaces.erase("com.sun.star.lang.XServiceInfo");
} else {
- if (interfaces.find("com.sun.star.lang.XServiceInfo") == interfaces.end())
- interfaces.insert("com.sun.star.lang.XServiceInfo");
+ interfaces.insert("com.sun.star.lang.XServiceInfo");
}
if ( propertyhelper == "_" ) {