refactor: remove LimitedQueueSnapshot (#6606)

Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2025-11-27 19:49:40 +01:00
committed by GitHub
parent a935965390
commit 30019b71aa
15 changed files with 40 additions and 173 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ bool checkMessageUserName(const QString &userName, MessagePtr message)
ChannelPtr filterMessages(const QString &userName, ChannelPtr channel)
{
LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot();
std::vector<MessagePtr> snapshot = channel->getMessageSnapshot();
ChannelPtr channelPtr;
if (channel->isTwitchChannel())
+5 -7
View File
@@ -13,7 +13,6 @@
#include "messages/layouts/MessageLayout.hpp"
#include "messages/layouts/MessageLayoutContext.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
@@ -693,7 +692,7 @@ void ChannelView::performLayout(bool causedByScrollbar, bool causedByShow)
}
void ChannelView::layoutVisibleMessages(
const LimitedQueueSnapshot<MessageLayoutPtr> &messages)
const std::vector<MessageLayoutPtr> &messages)
{
const auto start = size_t(this->scrollBar_->getRelativeCurrentValue());
const auto layoutWidth = this->getLayoutWidth();
@@ -731,9 +730,8 @@ void ChannelView::layoutVisibleMessages(
}
}
void ChannelView::updateScrollbar(
const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
bool causedByScrollbar, bool causedByShow)
void ChannelView::updateScrollbar(const std::vector<MessageLayoutPtr> &messages,
bool causedByScrollbar, bool causedByShow)
{
if (messages.size() == 0)
{
@@ -820,7 +818,7 @@ QString ChannelView::getSelectedText()
{
QString result = "";
LimitedQueueSnapshot<MessageLayoutPtr> &messagesSnapshot =
std::vector<MessageLayoutPtr> &messagesSnapshot =
this->getMessagesSnapshot();
Selection selection = this->selection_;
@@ -897,7 +895,7 @@ const std::optional<MessageElementFlags> &ChannelView::getOverrideFlags() const
return this->overrideFlags_;
}
LimitedQueueSnapshot<MessageLayoutPtr> &ChannelView::getMessagesSnapshot()
std::vector<MessageLayoutPtr> &ChannelView::getMessagesSnapshot()
{
this->snapshotGuard_.guard();
if (!this->paused() /*|| this->scrollBar_->isVisible()*/)
+4 -6
View File
@@ -3,7 +3,6 @@
#include "common/FlagsEnum.hpp"
#include "messages/layouts/MessageLayoutContext.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/MessageFlag.hpp"
#include "messages/Selection.hpp"
#include "util/ThreadGuard.hpp"
@@ -178,7 +177,7 @@ public:
/// Checks if this view has a #sourceChannel
bool hasSourceChannel() const;
LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();
std::vector<MessageLayoutPtr> &getMessagesSnapshot();
void queueLayout();
void invalidateBuffers();
@@ -286,9 +285,8 @@ private:
void performLayout(bool causedByScrollbar = false,
bool causedByShow = false);
void layoutVisibleMessages(
const LimitedQueueSnapshot<MessageLayoutPtr> &messages);
void updateScrollbar(const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
void layoutVisibleMessages(const std::vector<MessageLayoutPtr> &messages);
void updateScrollbar(const std::vector<MessageLayoutPtr> &messages,
bool causedByScrollbar, bool causedByShow);
void drawMessages(QPainter &painter, const QRect &area);
@@ -354,7 +352,7 @@ private:
MessageLayoutPtr lastReadMessage_;
ThreadGuard snapshotGuard_;
LimitedQueueSnapshot<MessageLayoutPtr> snapshot_;
std::vector<MessageLayoutPtr> snapshot_;
/// @brief The backing (internal) channel
///
+4 -7
View File
@@ -26,7 +26,7 @@
namespace chatterino {
ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
const LimitedQueueSnapshot<MessagePtr> &snapshot)
const std::vector<MessagePtr> &snapshot)
{
ChannelPtr channel(new Channel(channelName, Channel::Type::None));
@@ -233,7 +233,7 @@ void SearchPopup::search()
this->channelName_, this->snapshot_));
}
LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
std::vector<MessagePtr> SearchPopup::buildSnapshot()
{
// no point in filtering/sorting if it's a single channel search
if (this->searchChannels_.length() == 1)
@@ -248,7 +248,7 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
ChannelView &sharedView = channel.get();
const FilterSetPtr filterSet = sharedView.getFilterSet();
const LimitedQueueSnapshot<MessagePtr> &snapshot =
const std::vector<MessagePtr> &snapshot =
sharedView.channel()->getMessageSnapshot();
for (const auto &message : snapshot)
@@ -284,10 +284,7 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
return a->serverReceivedTime < b->serverReceivedTime;
});
auto queue = LimitedQueue<MessagePtr>(combinedSnapshot.size());
queue.pushFront(combinedSnapshot);
return queue.getSnapshot();
return combinedSnapshot;
}
void SearchPopup::initLayout()
+3 -4
View File
@@ -1,7 +1,6 @@
#pragma once
#include "ForwardDecl.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "widgets/BasePopup.hpp"
#include <memory>
@@ -38,7 +37,7 @@ private:
void initLayout();
void search();
void addShortcuts() override;
LimitedQueueSnapshot<MessagePtr> buildSnapshot();
std::vector<MessagePtr> buildSnapshot();
/**
* @brief Only retains those message from a list of messages that satisfy a
@@ -53,7 +52,7 @@ private:
* "snapshot"
*/
static ChannelPtr filter(const QString &text, const QString &channelName,
const LimitedQueueSnapshot<MessagePtr> &snapshot);
const std::vector<MessagePtr> &snapshot);
/**
* @brief Checks the input for tags and registers their corresponding
@@ -65,7 +64,7 @@ private:
static std::vector<std::unique_ptr<MessagePredicate>> parsePredicates(
const QString &input);
LimitedQueueSnapshot<MessagePtr> snapshot_;
std::vector<MessagePtr> snapshot_;
QLineEdit *searchInput_{};
ChannelView *channelView_{};
QString channelName_{};