Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/cpp/rtps/history/History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/common/CacheChange.hpp>

#include <rtps/common/ChangeComparison.hpp>
#include <rtps/history/BasicPayloadPool.hpp>
#include <rtps/history/CacheChangePool.h>

Expand Down Expand Up @@ -54,11 +55,15 @@ History::const_iterator History::find_change_nts(
return const_iterator();
}

return std::find_if(changesBegin(), changesEnd(), [this, ch](const CacheChange_t* chi)
{
// use the derived classes comparison criteria for searching
return this->matches_change(chi, ch);
});
// Use binary search to find the first change with the same sequence number
auto lb = std::lower_bound(changesBegin(), changesEnd(), ch, history_order_cmp);

if (lb != changesEnd() && matches_change(*lb, ch))
{
return lb;
}

return changesEnd();
}

bool History::matches_change(
Expand Down
Loading