refactor: remove LimitedQueueSnapshot (#6606)
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
- Dev: Set settings directory to temporary one used in tests. (#6584)
|
- Dev: Set settings directory to temporary one used in tests. (#6584)
|
||||||
- Dev: Check Lua unwinding and version in tests. (#6586)
|
- Dev: Check Lua unwinding and version in tests. (#6586)
|
||||||
- Dev: Added method to get the last N messages of a channel. (#6602, #6604)
|
- Dev: Added method to get the last N messages of a channel. (#6602, #6604)
|
||||||
|
- Dev: Unwrapped `LimitedQueueSnapshot` to `std::vector`. (#6606)
|
||||||
|
|
||||||
## 2.5.4
|
## 2.5.4
|
||||||
|
|
||||||
|
|||||||
@@ -71,13 +71,12 @@ bool Channel::hasMessages() const
|
|||||||
return !this->messages_.empty();
|
return !this->messages_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot() const
|
std::vector<MessagePtr> Channel::getMessageSnapshot() const
|
||||||
{
|
{
|
||||||
return this->messages_.getSnapshot();
|
return this->messages_.getSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot(
|
std::vector<MessagePtr> Channel::getMessageSnapshot(size_t nItems) const
|
||||||
size_t nItems) const
|
|
||||||
{
|
{
|
||||||
return this->messages_.lastN(nItems);
|
return this->messages_.lastN(nItems);
|
||||||
}
|
}
|
||||||
@@ -147,7 +146,7 @@ void Channel::addOrReplaceClearChat(MessagePtr message, const QDateTime &now)
|
|||||||
|
|
||||||
void Channel::disableAllMessages()
|
void Channel::disableAllMessages()
|
||||||
{
|
{
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
|
std::vector<MessagePtr> snapshot = this->getMessageSnapshot();
|
||||||
int snapshotLength = snapshot.size();
|
int snapshotLength = snapshot.size();
|
||||||
for (int i = 0; i < snapshotLength; i++)
|
for (int i = 0; i < snapshotLength; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ public:
|
|||||||
virtual const QString &getLocalizedName() const;
|
virtual const QString &getLocalizedName() const;
|
||||||
bool isTwitchChannel() const;
|
bool isTwitchChannel() const;
|
||||||
virtual bool isEmpty() const;
|
virtual bool isEmpty() const;
|
||||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot() const;
|
std::vector<MessagePtr> getMessageSnapshot() const;
|
||||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot(size_t nItems) const;
|
std::vector<MessagePtr> getMessageSnapshot(size_t nItems) const;
|
||||||
|
|
||||||
// MESSAGES
|
// MESSAGES
|
||||||
// overridingFlags can be filled in with flags that should be used instead
|
// overridingFlags can be filled in with flags that should be used instead
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ void NotificationController::notifyTwitchChannelLive(
|
|||||||
void NotificationController::notifyTwitchChannelOffline(const QString &id) const
|
void NotificationController::notifyTwitchChannelOffline(const QString &id) const
|
||||||
{
|
{
|
||||||
// "delete" old 'CHANNEL is live' message
|
// "delete" old 'CHANNEL is live' message
|
||||||
const LimitedQueueSnapshot<MessagePtr> snapshot =
|
const std::vector<MessagePtr> snapshot =
|
||||||
getApp()->getTwitch()->getLiveChannel()->getMessageSnapshot(200);
|
getApp()->getTwitch()->getLiveChannel()->getMessageSnapshot(200);
|
||||||
|
|
||||||
// Guard against empty snapshot to prevent underflow and invalid access
|
// Guard against empty snapshot to prevent underflow and invalid access
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
|
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -318,22 +316,28 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] LimitedQueueSnapshot<T> getSnapshot() const
|
[[nodiscard]] std::vector<T> getSnapshot() const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(this->mutex_);
|
std::shared_lock lock(this->mutex_);
|
||||||
return LimitedQueueSnapshot<T>(this->buffer_);
|
return {this->buffer_.begin(), this->buffer_.end()};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] LimitedQueueSnapshot<T> lastN(size_t nItems) const
|
[[nodiscard]] std::vector<T> lastN(size_t nItems) const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(this->mutex_);
|
std::shared_lock lock(this->mutex_);
|
||||||
return LimitedQueueSnapshot<T>::lastN(this->buffer_, nItems);
|
return {
|
||||||
|
this->buffer_.end() - std::min(nItems, this->buffer_.size()),
|
||||||
|
this->buffer_.end(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] LimitedQueueSnapshot<T> firstN(size_t nItems) const
|
[[nodiscard]] std::vector<T> firstN(size_t nItems) const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(this->mutex_);
|
std::shared_lock lock(this->mutex_);
|
||||||
return LimitedQueueSnapshot<T>::firstN(this->buffer_, nItems);
|
return {
|
||||||
|
this->buffer_.begin(),
|
||||||
|
this->buffer_.begin() + std::min(nItems, this->buffer_.size()),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <boost/circular_buffer.hpp>
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class LimitedQueue;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class LimitedQueueSnapshot
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
friend class LimitedQueue<T>;
|
|
||||||
|
|
||||||
LimitedQueueSnapshot(const boost::circular_buffer<T> &buf)
|
|
||||||
: buffer_(buf.begin(), buf.end())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static LimitedQueueSnapshot lastN(const boost::circular_buffer<T> &buf,
|
|
||||||
size_t n)
|
|
||||||
{
|
|
||||||
return {buf.end() - std::min(n, buf.size()), buf.end()};
|
|
||||||
}
|
|
||||||
|
|
||||||
static LimitedQueueSnapshot firstN(const boost::circular_buffer<T> &buf,
|
|
||||||
size_t n)
|
|
||||||
{
|
|
||||||
return {buf.begin(), buf.begin() + std::min(n, buf.size())};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename It>
|
|
||||||
LimitedQueueSnapshot(It begin, It end)
|
|
||||||
: buffer_(std::move(begin), std::move(end))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
LimitedQueueSnapshot() = default;
|
|
||||||
|
|
||||||
size_t size() const
|
|
||||||
{
|
|
||||||
return this->buffer_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
const T &operator[](size_t index) const
|
|
||||||
{
|
|
||||||
return this->buffer_[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
auto begin() const
|
|
||||||
{
|
|
||||||
return this->buffer_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto end() const
|
|
||||||
{
|
|
||||||
return this->buffer_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto rbegin() const
|
|
||||||
{
|
|
||||||
return this->buffer_.rbegin();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto rend() const
|
|
||||||
{
|
|
||||||
return this->buffer_.rend();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<T> buffer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp" // IWYU pragma: keep
|
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
@@ -115,7 +114,5 @@ void setSimilarityFlags(const MessagePtr &message, const T &messages)
|
|||||||
|
|
||||||
template void setSimilarityFlags<std::vector<MessagePtr>>(
|
template void setSimilarityFlags<std::vector<MessagePtr>>(
|
||||||
const MessagePtr &msg, const std::vector<MessagePtr> &messages);
|
const MessagePtr &msg, const std::vector<MessagePtr> &messages);
|
||||||
template void setSimilarityFlags<LimitedQueueSnapshot<MessagePtr>>(
|
|
||||||
const MessagePtr &msg, const LimitedQueueSnapshot<MessagePtr> &messages);
|
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -66,7 +64,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static float similarity(const MessagePtr &msg,
|
static float similarity(const MessagePtr &msg,
|
||||||
const LimitedQueueSnapshot<MessagePtr> &messages);
|
const std::vector<MessagePtr> &messages);
|
||||||
static void setSimilarityFlags(const MessagePtr &message,
|
static void setSimilarityFlags(const MessagePtr &message,
|
||||||
const ChannelPtr &channel);
|
const ChannelPtr &channel);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "common/Literals.hpp"
|
#include "common/Literals.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/bttv/BttvEmotes.hpp"
|
#include "providers/bttv/BttvEmotes.hpp"
|
||||||
@@ -480,7 +479,7 @@ void TwitchIrcServer::onReadConnected(IrcConnection *connection)
|
|||||||
|
|
||||||
for (const auto &chan : activeChannels)
|
for (const auto &chan : activeChannels)
|
||||||
{
|
{
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot = chan->getMessageSnapshot();
|
std::vector<MessagePtr> snapshot = chan->getMessageSnapshot();
|
||||||
|
|
||||||
bool replaceMessage =
|
bool replaceMessage =
|
||||||
snapshot.size() > 0 && snapshot[snapshot.size() - 1]->flags.has(
|
snapshot.size() > 0 && snapshot[snapshot.size() - 1]->flags.has(
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ bool checkMessageUserName(const QString &userName, MessagePtr message)
|
|||||||
|
|
||||||
ChannelPtr filterMessages(const QString &userName, ChannelPtr channel)
|
ChannelPtr filterMessages(const QString &userName, ChannelPtr channel)
|
||||||
{
|
{
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot();
|
std::vector<MessagePtr> snapshot = channel->getMessageSnapshot();
|
||||||
|
|
||||||
ChannelPtr channelPtr;
|
ChannelPtr channelPtr;
|
||||||
if (channel->isTwitchChannel())
|
if (channel->isTwitchChannel())
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "messages/layouts/MessageLayout.hpp"
|
#include "messages/layouts/MessageLayout.hpp"
|
||||||
#include "messages/layouts/MessageLayoutContext.hpp"
|
#include "messages/layouts/MessageLayoutContext.hpp"
|
||||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
#include "messages/MessageElement.hpp"
|
||||||
@@ -693,7 +692,7 @@ void ChannelView::performLayout(bool causedByScrollbar, bool causedByShow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::layoutVisibleMessages(
|
void ChannelView::layoutVisibleMessages(
|
||||||
const LimitedQueueSnapshot<MessageLayoutPtr> &messages)
|
const std::vector<MessageLayoutPtr> &messages)
|
||||||
{
|
{
|
||||||
const auto start = size_t(this->scrollBar_->getRelativeCurrentValue());
|
const auto start = size_t(this->scrollBar_->getRelativeCurrentValue());
|
||||||
const auto layoutWidth = this->getLayoutWidth();
|
const auto layoutWidth = this->getLayoutWidth();
|
||||||
@@ -731,9 +730,8 @@ void ChannelView::layoutVisibleMessages(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::updateScrollbar(
|
void ChannelView::updateScrollbar(const std::vector<MessageLayoutPtr> &messages,
|
||||||
const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
|
bool causedByScrollbar, bool causedByShow)
|
||||||
bool causedByScrollbar, bool causedByShow)
|
|
||||||
{
|
{
|
||||||
if (messages.size() == 0)
|
if (messages.size() == 0)
|
||||||
{
|
{
|
||||||
@@ -820,7 +818,7 @@ QString ChannelView::getSelectedText()
|
|||||||
{
|
{
|
||||||
QString result = "";
|
QString result = "";
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> &messagesSnapshot =
|
std::vector<MessageLayoutPtr> &messagesSnapshot =
|
||||||
this->getMessagesSnapshot();
|
this->getMessagesSnapshot();
|
||||||
|
|
||||||
Selection selection = this->selection_;
|
Selection selection = this->selection_;
|
||||||
@@ -897,7 +895,7 @@ const std::optional<MessageElementFlags> &ChannelView::getOverrideFlags() const
|
|||||||
return this->overrideFlags_;
|
return this->overrideFlags_;
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> &ChannelView::getMessagesSnapshot()
|
std::vector<MessageLayoutPtr> &ChannelView::getMessagesSnapshot()
|
||||||
{
|
{
|
||||||
this->snapshotGuard_.guard();
|
this->snapshotGuard_.guard();
|
||||||
if (!this->paused() /*|| this->scrollBar_->isVisible()*/)
|
if (!this->paused() /*|| this->scrollBar_->isVisible()*/)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "messages/layouts/MessageLayoutContext.hpp"
|
#include "messages/layouts/MessageLayoutContext.hpp"
|
||||||
#include "messages/LimitedQueue.hpp"
|
#include "messages/LimitedQueue.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
#include "messages/MessageFlag.hpp"
|
#include "messages/MessageFlag.hpp"
|
||||||
#include "messages/Selection.hpp"
|
#include "messages/Selection.hpp"
|
||||||
#include "util/ThreadGuard.hpp"
|
#include "util/ThreadGuard.hpp"
|
||||||
@@ -178,7 +177,7 @@ public:
|
|||||||
/// Checks if this view has a #sourceChannel
|
/// Checks if this view has a #sourceChannel
|
||||||
bool hasSourceChannel() const;
|
bool hasSourceChannel() const;
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();
|
std::vector<MessageLayoutPtr> &getMessagesSnapshot();
|
||||||
|
|
||||||
void queueLayout();
|
void queueLayout();
|
||||||
void invalidateBuffers();
|
void invalidateBuffers();
|
||||||
@@ -286,9 +285,8 @@ private:
|
|||||||
|
|
||||||
void performLayout(bool causedByScrollbar = false,
|
void performLayout(bool causedByScrollbar = false,
|
||||||
bool causedByShow = false);
|
bool causedByShow = false);
|
||||||
void layoutVisibleMessages(
|
void layoutVisibleMessages(const std::vector<MessageLayoutPtr> &messages);
|
||||||
const LimitedQueueSnapshot<MessageLayoutPtr> &messages);
|
void updateScrollbar(const std::vector<MessageLayoutPtr> &messages,
|
||||||
void updateScrollbar(const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
|
|
||||||
bool causedByScrollbar, bool causedByShow);
|
bool causedByScrollbar, bool causedByShow);
|
||||||
|
|
||||||
void drawMessages(QPainter &painter, const QRect &area);
|
void drawMessages(QPainter &painter, const QRect &area);
|
||||||
@@ -354,7 +352,7 @@ private:
|
|||||||
MessageLayoutPtr lastReadMessage_;
|
MessageLayoutPtr lastReadMessage_;
|
||||||
|
|
||||||
ThreadGuard snapshotGuard_;
|
ThreadGuard snapshotGuard_;
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> snapshot_;
|
std::vector<MessageLayoutPtr> snapshot_;
|
||||||
|
|
||||||
/// @brief The backing (internal) channel
|
/// @brief The backing (internal) channel
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
|
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));
|
ChannelPtr channel(new Channel(channelName, Channel::Type::None));
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ void SearchPopup::search()
|
|||||||
this->channelName_, this->snapshot_));
|
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
|
// no point in filtering/sorting if it's a single channel search
|
||||||
if (this->searchChannels_.length() == 1)
|
if (this->searchChannels_.length() == 1)
|
||||||
@@ -248,7 +248,7 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
|
|||||||
ChannelView &sharedView = channel.get();
|
ChannelView &sharedView = channel.get();
|
||||||
|
|
||||||
const FilterSetPtr filterSet = sharedView.getFilterSet();
|
const FilterSetPtr filterSet = sharedView.getFilterSet();
|
||||||
const LimitedQueueSnapshot<MessagePtr> &snapshot =
|
const std::vector<MessagePtr> &snapshot =
|
||||||
sharedView.channel()->getMessageSnapshot();
|
sharedView.channel()->getMessageSnapshot();
|
||||||
|
|
||||||
for (const auto &message : snapshot)
|
for (const auto &message : snapshot)
|
||||||
@@ -284,10 +284,7 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
|
|||||||
return a->serverReceivedTime < b->serverReceivedTime;
|
return a->serverReceivedTime < b->serverReceivedTime;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto queue = LimitedQueue<MessagePtr>(combinedSnapshot.size());
|
return combinedSnapshot;
|
||||||
queue.pushFront(combinedSnapshot);
|
|
||||||
|
|
||||||
return queue.getSnapshot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPopup::initLayout()
|
void SearchPopup::initLayout()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ForwardDecl.hpp"
|
#include "ForwardDecl.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
|
||||||
#include "widgets/BasePopup.hpp"
|
#include "widgets/BasePopup.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -38,7 +37,7 @@ private:
|
|||||||
void initLayout();
|
void initLayout();
|
||||||
void search();
|
void search();
|
||||||
void addShortcuts() override;
|
void addShortcuts() override;
|
||||||
LimitedQueueSnapshot<MessagePtr> buildSnapshot();
|
std::vector<MessagePtr> buildSnapshot();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Only retains those message from a list of messages that satisfy a
|
* @brief Only retains those message from a list of messages that satisfy a
|
||||||
@@ -53,7 +52,7 @@ private:
|
|||||||
* "snapshot"
|
* "snapshot"
|
||||||
*/
|
*/
|
||||||
static ChannelPtr filter(const QString &text, const QString &channelName,
|
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
|
* @brief Checks the input for tags and registers their corresponding
|
||||||
@@ -65,7 +64,7 @@ private:
|
|||||||
static std::vector<std::unique_ptr<MessagePredicate>> parsePredicates(
|
static std::vector<std::unique_ptr<MessagePredicate>> parsePredicates(
|
||||||
const QString &input);
|
const QString &input);
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot_;
|
std::vector<MessagePtr> snapshot_;
|
||||||
QLineEdit *searchInput_{};
|
QLineEdit *searchInput_{};
|
||||||
ChannelView *channelView_{};
|
ChannelView *channelView_{};
|
||||||
QString channelName_{};
|
QString channelName_{};
|
||||||
|
|||||||
@@ -6,55 +6,12 @@
|
|||||||
|
|
||||||
using namespace chatterino;
|
using namespace chatterino;
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::ostream &operator<<(std::ostream &os,
|
inline void SNAPSHOT_EQUALS(const std::vector<T> &snapshot,
|
||||||
const LimitedQueueSnapshot<T> &snapshot)
|
|
||||||
{
|
|
||||||
os << "[ ";
|
|
||||||
for (size_t i = 0; i < snapshot.size(); ++i)
|
|
||||||
{
|
|
||||||
os << snapshot[i] << ' ';
|
|
||||||
}
|
|
||||||
os << "]";
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template <typename T>
|
|
||||||
std::ostream &operator<<(std::ostream &os, const vector<T> &vec)
|
|
||||||
{
|
|
||||||
os << "[ ";
|
|
||||||
for (const auto &item : vec)
|
|
||||||
{
|
|
||||||
os << item << ' ';
|
|
||||||
}
|
|
||||||
os << "]";
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void SNAPSHOT_EQUALS(const LimitedQueueSnapshot<T> &snapshot,
|
|
||||||
const std::vector<T> &values,
|
const std::vector<T> &values,
|
||||||
const std::string &msg)
|
const std::string &msg)
|
||||||
{
|
{
|
||||||
SCOPED_TRACE(msg);
|
EXPECT_EQ(snapshot, values) << msg;
|
||||||
ASSERT_EQ(snapshot.size(), values.size())
|
|
||||||
<< "snapshot = " << snapshot << " values = " << values;
|
|
||||||
|
|
||||||
if (snapshot.size() != values.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < snapshot.size(); ++i)
|
|
||||||
{
|
|
||||||
EXPECT_EQ(snapshot[i], values[i]) << "i = " << i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LimitedQueue, PushBack)
|
TEST(LimitedQueue, PushBack)
|
||||||
|
|||||||
Reference in New Issue
Block a user