From 0d7efa70ededec293590e02bace2b2864ca0d892 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 12 Aug 2019 13:14:46 +0200 Subject: [PATCH] Optimize cppu::supportsService to use const methods of Sequence ... and standard algorithm instead of loop. Change-Id: Ic90fa7e227807768f094b9fc231f3ba3d48e6139 Reviewed-on: https://gerrit.libreoffice.org/77350 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- cppuhelper/source/supportsservice.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cppuhelper/source/supportsservice.cxx b/cppuhelper/source/supportsservice.cxx index 629981310354..eea82602a2ef 100644 --- a/cppuhelper/source/supportsservice.cxx +++ b/cppuhelper/source/supportsservice.cxx @@ -9,6 +9,7 @@ #include +#include #include #include @@ -21,14 +22,9 @@ bool cppu::supportsService( css::lang::XServiceInfo * implementation, OUString const & name) { assert(implementation != nullptr); - css::uno::Sequence< OUString > s( + const css::uno::Sequence< OUString > s( implementation->getSupportedServiceNames()); - for (sal_Int32 i = 0; i != s.getLength(); ++i) { - if (s[i] == name) { - return true; - } - } - return false; + return std::find(s.begin(), s.end(), name) != s.end(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */