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 <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2019-08-12 16:29:53 +02:00
parent 972040a6b1
commit 0d7efa70ed
+3 -7
View File
@@ -9,6 +9,7 @@
#include <sal/config.h>
#include <algorithm>
#include <cassert>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -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: */