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 <sal/config.h>
#include <algorithm>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <new> #include <new>
@@ -317,13 +318,9 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
type.makeComplete(); type.makeComplete();
typelib_EnumTypeDescription * etd = typelib_EnumTypeDescription * etd =
reinterpret_cast< typelib_EnumTypeDescription * >(type.get()); reinterpret_cast< typelib_EnumTypeDescription * >(type.get());
bool bFound = false; bool bFound = std::any_of(
for (sal_Int32 i = 0; i != etd->nEnumValues; ++i) { etd->pEnumValues, etd->pEnumValues + etd->nEnumValues,
if (etd->pEnumValues[i] == v) { [v](sal_Int32 nValue) { return nValue == v; });
bFound = true;
break;
}
}
if (!bFound) { if (!bFound) {
throw css::io::IOException( throw css::io::IOException(
u"binaryurp::Unmarshal: unknown enum value"_ustr); u"binaryurp::Unmarshal: unknown enum value"_ustr);