diff --git a/worker/src/RTC/SeqManager.cpp b/worker/src/RTC/SeqManager.cpp index 3cd9958ab4..11dcd9a03c 100644 --- a/worker/src/RTC/SeqManager.cpp +++ b/worker/src/RTC/SeqManager.cpp @@ -1,6 +1,7 @@ #define MS_CLASS "RTC::SeqManager" // #define MS_LOG_DEV_LEVEL 3 +#include #include "RTC/SeqManager.hpp" #include "Logger.hpp" @@ -94,8 +95,8 @@ namespace RTC } // Count dropped entries before 'input' in order to adapt the base. - size_t dropped = std::count_if( - this->dropped.begin(), this->dropped.end(), [&input](T i) { return i < input; }); + size_t dropped = this->dropped.size() + - std::distance(this->dropped.upper_bound(input) , this->dropped.end()); base -= dropped; } diff --git a/worker/test/src/RTC/TestSeqManager.cpp b/worker/test/src/RTC/TestSeqManager.cpp index 6c2974bce4..feec3fcbcf 100644 --- a/worker/test/src/RTC/TestSeqManager.cpp +++ b/worker/test/src/RTC/TestSeqManager.cpp @@ -402,4 +402,26 @@ SCENARIO("SeqManager", "[rtc]") SeqManager seqManager; validate(seqManager, inputs); } + + SECTION("sync and drop some input near max-value") + { + // clang-format off + std::vector> inputs = + { + { 65530, 1, true, false }, + { 65531, 2, false, false }, + { 65532, 3, false, false }, + { 65533, 0, false, true }, + { 65534, 0, false, true }, + { 65535, 4, false, false }, + { 0, 5, false, false }, + { 1, 6, false, false }, + { 2, 7, false, false }, + { 3, 8, false, false } + }; + // clang-format on + + SeqManager seqManager; + validate(seqManager, inputs); + } }