Skip to content

Commit

Permalink
SeqManager.cpp: fix num discontinued problem and increase performance (
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinol authored May 11, 2020
1 parent 26b2df1 commit 2a0f14b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions worker/src/RTC/SeqManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define MS_CLASS "RTC::SeqManager"
// #define MS_LOG_DEV_LEVEL 3

#include <iterator>
#include "RTC/SeqManager.hpp"
#include "Logger.hpp"

Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions worker/test/src/RTC/TestSeqManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,26 @@ SCENARIO("SeqManager", "[rtc]")
SeqManager<uint16_t> seqManager;
validate(seqManager, inputs);
}

SECTION("sync and drop some input near max-value")
{
// clang-format off
std::vector<TestSeqManagerInput<uint16_t>> 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<uint16_t> seqManager;
validate(seqManager, inputs);
}
}

0 comments on commit 2a0f14b

Please sign in to comment.