From 426eb2fc67ac85b3a3ffb9acbf35339aeafcb2cd Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 24 Oct 2022 04:39:38 +0800 Subject: [PATCH] Cabana: use deque::resize() instead of pop_back in loop (#26209) use resize instead of pop_front in loop old-commit-hash: 0844662f845130bb536d7c8cad093fffbdefd761 --- tools/cabana/canmessages.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cabana/canmessages.cc b/tools/cabana/canmessages.cc index d88f34801b..d2141c3630 100644 --- a/tools/cabana/canmessages.cc +++ b/tools/cabana/canmessages.cc @@ -71,8 +71,8 @@ void CANMessages::process(QHash> *messages) { msgs = std::move(new_msgs); } else { msgs.insert(msgs.begin(), std::make_move_iterator(new_msgs.begin()), std::make_move_iterator(new_msgs.end())); - while (msgs.size() >= settings.can_msg_log_size) { - msgs.pop_back(); + if (msgs.size() > settings.can_msg_log_size) { + msgs.resize(settings.can_msg_log_size); } } }