switch from QHash to std::unordered_map

This commit is contained in:
unknown 2024-10-17 17:25:54 +02:00
parent 13d7692a89
commit a2af8e791b
2 changed files with 13 additions and 17 deletions

View file

@ -305,22 +305,13 @@ bool NotebookTab::isSelected() const
}
void NotebookTab::updateHighlightSources(
const QHash<ChannelPtr, HighlightEvent> &removedHighlightSources)
const std::unordered_map<ChannelPtr, HighlightEvent>
&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)

View file

@ -118,7 +118,8 @@ private:
};
void updateHighlightSources(
const QHash<ChannelPtr, HighlightEvent> &removedHighlightSources);
const std::unordered_map<ChannelPtr, HighlightEvent>
&removedHighlightSources);
QPropertyAnimation positionChangedAnimation_;
QPoint positionAnimationDesiredPoint_;
@ -148,7 +149,7 @@ private:
QMenu menu_;
QHash<ChannelPtr, HighlightEvent> highlightSources_;
std::unordered_map<ChannelPtr, HighlightEvent> highlightSources_;
pajlada::Signals::SignalHolder managedConnections_;
};