Extract entry list truncation.

This commit is contained in:
Jared Boone
2015-12-05 19:52:12 -08:00
parent 9791d64b50
commit 8fce9378cc
2 changed files with 9 additions and 3 deletions
+7 -3
View File
@@ -349,6 +349,12 @@ void AISView::on_hide() {
View::on_hide();
}
void AISView::truncate_entries() {
while(recent.size() > 64) {
recent.pop_back();
}
}
void AISView::on_packet(const baseband::ais::Packet& packet) {
const auto source_id = packet.source_id();
auto matching_recent = std::find_if(recent.begin(), recent.end(),
@@ -360,9 +366,7 @@ void AISView::on_packet(const baseband::ais::Packet& packet) {
recent.erase(matching_recent);
} else {
recent.emplace_front(source_id);
while(recent.size() > 64) {
recent.pop_back();
}
truncate_entries();
}
auto& entry = recent.front();