diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-08-12 13:14:46 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-08-12 16:29:53 +0200 |
commit | 0d7efa70ededec293590e02bace2b2864ca0d892 (patch) | |
tree | 1f40fedc65368ca8738bd7bd3e55182b11ffedf3 /cppuhelper/source/supportsservice.cxx | |
parent | 972040a6b13951469f0490d3d2aeba147ec22244 (diff) |
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>
Diffstat (limited to 'cppuhelper/source/supportsservice.cxx')
-rw-r--r-- | cppuhelper/source/supportsservice.cxx | 10 |
1 files 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 <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: */ |