From a2af8e791b91ce8337f2dd1cdf03f8c27cd92b51 Mon Sep 17 00:00:00 2001 From: unknown <1310440+hemirt@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:25:54 +0200 Subject: [PATCH] switch from QHash to std::unordered_map --- src/widgets/helper/NotebookTab.cpp | 25 ++++++++++--------------- src/widgets/helper/NotebookTab.hpp | 5 +++-- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 8b08c1bbd..febfbd305 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -305,22 +305,13 @@ bool NotebookTab::isSelected() const } void NotebookTab::updateHighlightSources( - const QHash &removedHighlightSources) + const std::unordered_map + &removedHighlightSources) { -#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) - for (const auto &[otherChannel, otherEvent] : - removedHighlightSources.asKeyValueRange()) + for (const auto &[otherChannel, otherEvent] : removedHighlightSources) { - this->highlightSources_.remove(otherChannel); + this->highlightSources_.erase(otherChannel); } -#else - for (auto it = removedHighlightSources.cbegin(), - end = removedHighlightSources.cend(); - it != end; ++it) - { - this->highlightSources_.remove(it.key()); - } -#endif if (this->highlightSources_.empty()) { @@ -446,8 +437,12 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle, return; } - this->highlightSources_.insert(channelViewSource.underlyingChannel(), - HighlightEvent{}); + if (!this->highlightSources_.contains( + channelViewSource.underlyingChannel())) + { + this->highlightSources_.emplace(channelViewSource.underlyingChannel(), + HighlightEvent{}); + } if (!this->highlightEnabled_ && newHighlightStyle == HighlightState::NewMessage) diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index c709eb42e..a7b1e518e 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -118,7 +118,8 @@ private: }; void updateHighlightSources( - const QHash &removedHighlightSources); + const std::unordered_map + &removedHighlightSources); QPropertyAnimation positionChangedAnimation_; QPoint positionAnimationDesiredPoint_; @@ -148,7 +149,7 @@ private: QMenu menu_; - QHash highlightSources_; + std::unordered_map highlightSources_; pajlada::Signals::SignalHolder managedConnections_; };