Speed up lookup time

By adding another variable we can get O(1) lookup time instead of O(n).
Fix up 5f415c292d.
This commit is contained in:
Chocobo1
2020-01-30 13:37:46 +08:00
parent a2ebd77eac
commit ff31bb86bc
2 changed files with 14 additions and 8 deletions

View File

@@ -30,6 +30,7 @@
#define PEERLISTWIDGET_H
#include <QHash>
#include <QSet>
#include <QTreeView>
class QHostAddress;
@@ -85,6 +86,7 @@ private:
PropertiesWidget *m_properties = nullptr;
Net::ReverseResolution *m_resolver = nullptr;
QHash<PeerEndpoint, QStandardItem *> m_peerItems;
QHash<QHostAddress, QSet<QStandardItem *>> m_itemsByIP; // must be kept in sync with `m_peerItems`
bool m_resolveCountries;
};