From be0aa5f30af7506265ec71045fdb66c1f2460a4e Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 7 Sep 2021 10:17:18 +0200 Subject: [PATCH] Refs 12400. Fixed DataReaderHistory. Signed-off-by: Miguel Company --- .../fastdds/subscriber/history/DataReaderHistory.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp index bc56f611891..5c1adfe6d33 100644 --- a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp +++ b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp @@ -28,6 +28,7 @@ #include #include +#include namespace eprosima { namespace fastdds { @@ -305,10 +306,11 @@ bool DataReaderHistory::add_received_change_with_key( } //ADD TO KEY VECTOR - - // As the instance should be ordered following the presentation QoS, and - // we only support ordering by reception timestamp, we can always add at the end. - instance_changes.push_back(a_change); + eprosima::utilities::collections::sorted_vector_insert(instance_changes, a_change, + [](const CacheChange_t* lhs, const CacheChange_t* rhs) + { + return lhs->sourceTimestamp < rhs->sourceTimestamp; + }); logInfo(SUBSCRIBER, mp_reader->getGuid().entityId << ": Change " << a_change->sequenceNumber << " added from: "