Browse Source

Cache country lookup result in PeerInfo class

The country lookup happens quite often when "Resolve peer countries"
option is enabled.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
472dd96716
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 4
      src/base/bittorrent/peerinfo.cpp
  2. 4
      src/base/bittorrent/peerinfo.h

4
src/base/bittorrent/peerinfo.cpp

@ -64,7 +64,9 @@ bool PeerInfo::fromLSD() const @@ -64,7 +64,9 @@ bool PeerInfo::fromLSD() const
#ifndef DISABLE_COUNTRIES_RESOLUTION
QString PeerInfo::country() const
{
return Net::GeoIPManager::instance()->lookup(address().ip);
if (m_country.isEmpty())
m_country = Net::GeoIPManager::instance()->lookup(address().ip);
return m_country;
}
#endif

4
src/base/bittorrent/peerinfo.h

@ -102,6 +102,10 @@ namespace BitTorrent @@ -102,6 +102,10 @@ namespace BitTorrent
qreal m_relevance = 0;
QString m_flags;
QString m_flagsDescription;
#ifndef DISABLE_COUNTRIES_RESOLUTION
mutable QString m_country;
#endif
};
}

Loading…
Cancel
Save