From d990e59f2de15a80b170e23a7872c1d9742584f1 Mon Sep 17 00:00:00 2001 From: penguinol Date: Mon, 11 May 2020 17:15:07 +0800 Subject: [PATCH 1/3] fix secquence num discontiued problem and increase performance of seqManager --- worker/src/RTC/SeqManager.cpp | 4 ++-- worker/test/src/RTC/TestSeqManager.cpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/worker/src/RTC/SeqManager.cpp b/worker/src/RTC/SeqManager.cpp index 04abd07fe6..080b5732de 100644 --- a/worker/src/RTC/SeqManager.cpp +++ b/worker/src/RTC/SeqManager.cpp @@ -88,8 +88,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 91b8dd872a..f3b5a2fd27 100644 --- a/worker/test/src/RTC/TestSeqManager.cpp +++ b/worker/test/src/RTC/TestSeqManager.cpp @@ -282,4 +282,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); + } } From 47b0faf8f9ab1c040d18ab11bc24fa6acc2ba233 Mon Sep 17 00:00:00 2001 From: penguinol Date: Mon, 11 May 2020 18:01:53 +0800 Subject: [PATCH 2/3] Update TestSeqManager.cpp --- worker/test/src/RTC/TestSeqManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/test/src/RTC/TestSeqManager.cpp b/worker/test/src/RTC/TestSeqManager.cpp index 4e74daf973..feec3fcbcf 100644 --- a/worker/test/src/RTC/TestSeqManager.cpp +++ b/worker/test/src/RTC/TestSeqManager.cpp @@ -406,7 +406,7 @@ SCENARIO("SeqManager", "[rtc]") SECTION("sync and drop some input near max-value") { // clang-format off - std::vector inputs = + std::vector> inputs = { { 65530, 1, true, false }, { 65531, 2, false, false }, From 77c89451ed651d3c6fe0c43b789f1686cfdca5a3 Mon Sep 17 00:00:00 2001 From: penguinol Date: Mon, 11 May 2020 18:07:34 +0800 Subject: [PATCH 3/3] Update SeqManager.cpp --- worker/src/RTC/SeqManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/worker/src/RTC/SeqManager.cpp b/worker/src/RTC/SeqManager.cpp index c819a3a968..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"