diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index f3de1c96700cb0f885a8431837e6d0e515ee8fc4..1097bae0a6e05cad135ec023cb4ef54c8d73082a 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -403,17 +403,13 @@ void KafkaEventStreamDecoder::eventDataFromMessage(const std::string &buffer, const auto oldBufferSize(m_receivedEventBuffer.size()); m_receivedEventBuffer.reserve(oldBufferSize + nEvents); - /* Store the buffered events */ - for (flatbuffers::uoffset_t i = 0; i < nEvents; ++i) { - auto detId = detData[i]; - auto tof = tofData[i]; - uint32_t index = detId + m_specToIdxOffset; - if (index < m_specToIdx.size()) { - const auto workspaceIndex = m_specToIdx[index]; - auto event = BufferedEvent{workspaceIndex, tof, pulseIndex}; - m_receivedEventBuffer.emplace_back(std::move(event)); - } - } + std::transform(detData.begin(), detData.end(), tofData.begin(), + std::back_inserter(m_receivedEventBuffer), + [&](uint64_t detId, uint64_t tof) -> BufferedEvent { + const auto workspaceIndex = + m_specToIdx[detId + m_specToIdxOffset]; + return {workspaceIndex, tof, pulseIndex}; + }); } const auto endTime = std::chrono::system_clock::now(); @@ -450,7 +446,7 @@ void KafkaEventStreamDecoder::flushIntermediateBuffer() { ws->invalidateCommonBinsFlag(); } - // PARALLEL_FOR_NO_WSP_CHECK() + PARALLEL_FOR_NO_WSP_CHECK() for (auto group = 0; group < numberOfGroups; ++group) { for (auto idx = groupBoundaries[group]; idx < groupBoundaries[group + 1]; ++idx) {