Optimize force read return values (#7596)

This commit is contained in:
Krzysztof Bieganski 2026-05-15 02:26:02 +02:00 committed by GitHub
parent d66733aeb8
commit a42c8587cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 6 deletions

View File

@ -222,11 +222,12 @@ public:
VlForceVec() = default;
template <typename T>
T read(T val) const {
T read(const T& val) const {
T result = val;
if VL_CONSTEXPR_CXX17 (VlForceTypeInfo<T>::unpackedArray) {
// Handling the case of a nested flattened array using recursion
using ElemRef
= decltype(VlForceArrayIndexer<T>::elem(val, static_cast<std::size_t>(0)));
= decltype(VlForceArrayIndexer<T>::elem(result, static_cast<std::size_t>(0)));
using Elem = VlForceBaseType<ElemRef>;
const int total = static_cast<int>(VlForceArrayIndexer<T>::size);
for (const auto& entry : m_entries) {
@ -236,13 +237,13 @@ public:
for (int idx = startIdx; idx <= endIdx; idx++) {
const int rhsIndex = idx - entry.m_rhsLsb;
const std::size_t uidx = static_cast<std::size_t>(idx);
VlForceArrayIndexer<T>::elem(val, uidx) = rhsBasep[rhsIndex];
VlForceArrayIndexer<T>::elem(result, uidx) = rhsBasep[rhsIndex];
}
}
return val;
return result;
}
applyEntries(val);
return val;
applyEntries(result);
return result;
}
template <typename T>