tdf#153109 replace for loop in unmarshal.cxx

Replaced a manual for-loop used for searching an array with std::any_of from the <algorithm> header.

Change-Id: I0a3f6b46e22ef92449a637f4164a0e47f794b598
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204585
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Asad Tauqeer
2026-05-07 21:15:19 +02:00
committed by Julien Nabet
parent 3f011d3b31
commit 241e14a762
+4 -7
View File
@@ -19,6 +19,7 @@
#include <sal/config.h>
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <new>
@@ -317,13 +318,9 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
type.makeComplete();
typelib_EnumTypeDescription * etd =
reinterpret_cast< typelib_EnumTypeDescription * >(type.get());
bool bFound = false;
for (sal_Int32 i = 0; i != etd->nEnumValues; ++i) {
if (etd->pEnumValues[i] == v) {
bFound = true;
break;
}
}
bool bFound = std::any_of(
etd->pEnumValues, etd->pEnumValues + etd->nEnumValues,
[v](sal_Int32 nValue) { return nValue == v; });
if (!bFound) {
throw css::io::IOException(
u"binaryurp::Unmarshal: unknown enum value"_ustr);