Skip to content

Commit

Permalink
DPL: avoid invoking matchDataHeader twice (#12632)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf authored Feb 1, 2024
1 parent 0162e3a commit b9f6e7d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Framework/Core/include/Framework/DataAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ class DataAllocator
decltype(auto) make(const Output& spec, Args... args)
{
auto& timingInfo = mRegistry.get<TimingInfo>();
auto routeIndex = matchDataHeader(spec, timingInfo.timeslice);
auto& context = mRegistry.get<MessageContext>();

if constexpr (is_specialization_v<T, UninitializedVector>) {
auto routeIndex = matchDataHeader(spec, timingInfo.timeslice);
// plain buffer as polymorphic spectator std::vector, which does not run constructors / destructors
using ValueType = typename T::value_type;

Expand All @@ -187,6 +187,7 @@ class DataAllocator
std::move(headerMessage), routeIndex, 0, std::forward<Args>(args)...)
.get();
} else if constexpr (is_specialization_v<T, std::vector> && has_messageable_value_type<T>::value) {
auto routeIndex = matchDataHeader(spec, timingInfo.timeslice);
// this catches all std::vector objects with messageable value type before checking if is also
// has a root dictionary, so non-serialized transmission is preferred
using ValueType = typename T::value_type;
Expand All @@ -195,6 +196,7 @@ class DataAllocator
fair::mq::MessagePtr headerMessage = headerMessageFromOutput(spec, routeIndex, o2::header::gSerializationMethodNone, 0);
return context.add<MessageContext::VectorObject<ValueType>>(std::move(headerMessage), routeIndex, 0, std::forward<Args>(args)...).get();
} else if constexpr (has_root_dictionary<T>::value == true && is_messageable<T>::value == false) {
auto routeIndex = matchDataHeader(spec, timingInfo.timeslice);
// Extended support for types implementing the Root ClassDef interface, both TObject
// derived types and others
if constexpr (enable_root_serialization<T>::value) {
Expand Down Expand Up @@ -233,6 +235,7 @@ class DataAllocator
if constexpr (is_messageable<T>::value == true) {
auto [nElements] = std::make_tuple(args...);
auto size = nElements * sizeof(T);
auto routeIndex = matchDataHeader(spec, timingInfo.timeslice);

fair::mq::MessagePtr headerMessage = headerMessageFromOutput(spec, routeIndex, o2::header::gSerializationMethodNone, size);
return context.add<MessageContext::SpanObject<T>>(std::move(headerMessage), routeIndex, 0, nElements).get();
Expand Down

0 comments on commit b9f6e7d

Please sign in to comment.