diff options
author | Paris Oplopoios <paris.oplopoios@collabora.com> | 2023-06-12 02:11:44 +0300 |
---|---|---|
committer | Paris Oplopoios <parisoplop@gmail.com> | 2023-06-12 13:11:07 +0200 |
commit | 81e815edbf5b4694789aa1d7b9e3ecde08b08b21 (patch) | |
tree | cc230423cb1fd0f1de078c18f9fd176c7320cd8d | |
parent | cf0fe26f95b5435d65623165cf7ba381eaa0738a (diff) |
tdf#153109 Use any_of instead of loop to check a range
Change-Id: Icf65288a7e53257008129b71e8d716b0b0c7f5fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152868
Tested-by: Paris Oplopoios <parisoplop@gmail.com>
Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
-rw-r--r-- | cppuhelper/source/typemanager.cxx | 9 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 6 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 8 |
3 files changed, 7 insertions, 16 deletions
diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx index 0408234c4b39..29f7025cdf6a 100644 --- a/cppuhelper/source/typemanager.cxx +++ b/cppuhelper/source/typemanager.cxx @@ -19,6 +19,7 @@ #include <string_view> #include <utility> #include <vector> +#include <algorithm> #include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -1723,12 +1724,8 @@ bool Enumeration::matches(css::uno::TypeClass tc) const { if (!types_.hasElements()) { return true; } - for (const auto & i : types_) { - if (i == tc) { - return true; - } - } - return false; + + return std::any_of(types_.begin(), types_.end(), [&tc](const auto& i) { return i == tc; }); } void Enumeration::findNextMatch() { diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 318da6536df9..7959b9c2ba83 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -19,6 +19,7 @@ #include <memory> #include <utility> +#include <algorithm> #include <string_view> #include <sal/config.h> @@ -175,10 +176,7 @@ static bool lcl_IsSymbolChar( CharClass const & rCC, const OUString& rTxt, static bool lcl_IsInArr(std::u16string_view arr, const sal_uInt32 c) { - for (const auto c1 : arr) - if (c1 == c) - return true; - return false; + return std::any_of(arr.begin(), arr.end(), [c](const auto c1) { return c1 == c; }); } SvxAutoCorrDoc::~SvxAutoCorrDoc() diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 6ab8eb844580..1f74c795d3f9 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -3789,12 +3789,8 @@ EscherPersistTable::~EscherPersistTable() bool EscherPersistTable::PtIsID( sal_uInt32 nID ) { - for(auto const & pPtr : maPersistTable) { - if ( pPtr->mnID == nID ) { - return true; - } - } - return false; + return std::any_of(maPersistTable.begin(), maPersistTable.end(), + [&nID](const auto& rxEntry) { return rxEntry->mnID == nID; }); } void EscherPersistTable::PtInsert( sal_uInt32 nID, sal_uInt32 nOfs ) |