[Libreoffice-commits] core.git: cppuhelper/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 12 14:31:32 UTC 2019
cppuhelper/source/supportsservice.cxx | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
New commits:
commit 0d7efa70ededec293590e02bace2b2864ca0d892
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Aug 12 13:14:46 2019 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Aug 12 16:29:53 2019 +0200
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 at collabora.com>
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 <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: */
More information about the Libreoffice-commits
mailing list