summaryrefslogtreecommitdiff
path: root/scripting/source/provider/ProviderCache.cxx
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-27 23:20:29 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-30 11:16:00 +0200
commit5ba84c3c7080d55d86b8b39db077b6da36cb700a (patch)
treea71491f3d336a314ab63e834bd013f0503be967b /scripting/source/provider/ProviderCache.cxx
parent850693273970be2662cce8f4d2710b3657a02f65 (diff)
Simplify Sequence iterations in scaddins, sccomp, scripting
Use range-based loops, STL and comphelper functions Change-Id: I836422a1c81a3dc9585687ed2e506eb59bb4ec91 Reviewed-on: https://gerrit.libreoffice.org/76484 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'scripting/source/provider/ProviderCache.cxx')
-rw-r--r--scripting/source/provider/ProviderCache.cxx27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx
index cf54ea0aee22..e97be35acb6f 100644
--- a/scripting/source/provider/ProviderCache.cxx
+++ b/scripting/source/provider/ProviderCache.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/sequence.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/factory.hxx>
#include <tools/diagnose_ex.h>
@@ -150,17 +151,17 @@ ProviderCache::populateCache()
if ( serviceNames.hasElements() )
{
- for ( sal_Int32 index = 0; index < serviceNames.getLength(); index++ )
+ auto pName = std::find_if(serviceNames.begin(), serviceNames.end(),
+ [this](const OUString& rName) {
+ return rName.startsWith("com.sun.star.script.provider.ScriptProviderFor")
+ && !isInBlackList(rName);
+ });
+ if (pName != serviceNames.end())
{
- if ( serviceNames[ index ].startsWith( "com.sun.star.script.provider.ScriptProviderFor" )
- && !isInBlackList( serviceNames[ index ] ) )
- {
- serviceName = serviceNames[ index ];
- ProviderDetails details;
- details.factory = factory;
- m_hProviderDetailsCache[ serviceName ] = details;
- break;
- }
+ serviceName = *pName;
+ ProviderDetails details;
+ details.factory = factory;
+ m_hProviderDetailsCache[ serviceName ] = details;
}
}
}
@@ -193,6 +194,12 @@ ProviderCache::createProvider( ProviderDetails& details )
return details.provider;
}
+
+bool
+ProviderCache::isInBlackList( const OUString& serviceName )
+{
+ return comphelper::findValue(m_sBlackList, serviceName) != -1;
+}
} //end namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */