Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeqManager.cpp: fix num discontinued bug and increase performance #396

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
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
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>
ibc marked this conversation as resolved.
Show resolved Hide resolved
#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);
}
}