Browse Source

Faster GeoIP lookups.

QCache results in speed decrease.
See https://github.com/qbittorrent/qBittorrent/pull/3488#issuecomment-124731983
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
ad7ad8f596
  1. 12
      src/core/net/geoipmanager.cpp
  2. 1
      src/core/net/geoipmanager.h

12
src/core/net/geoipmanager.cpp

@ -57,7 +57,6 @@ GeoIPManager *GeoIPManager::m_instance = 0; @@ -57,7 +57,6 @@ GeoIPManager *GeoIPManager::m_instance = 0;
GeoIPManager::GeoIPManager()
: m_enabled(false)
, m_geoIPDatabase(0)
, m_cache(CACHE_SIZE)
{
configure();
connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure()));
@ -126,15 +125,8 @@ void GeoIPManager::downloadDatabaseFile() @@ -126,15 +125,8 @@ void GeoIPManager::downloadDatabaseFile()
QString GeoIPManager::lookup(const QHostAddress &hostAddr) const
{
if (m_enabled && m_geoIPDatabase) {
QString *country = m_cache.object(hostAddr);
if (country)
return *country;
QString code = m_geoIPDatabase->lookup(hostAddr);
m_cache.insert(hostAddr, new QString(code));
return code;
}
if (m_enabled && m_geoIPDatabase)
return m_geoIPDatabase->lookup(hostAddr);
return QString();
}

1
src/core/net/geoipmanager.h

@ -68,7 +68,6 @@ namespace Net @@ -68,7 +68,6 @@ namespace Net
bool m_enabled;
GeoIPDatabase *m_geoIPDatabase;
mutable QCache<QHostAddress, QString> m_cache;
static GeoIPManager *m_instance;
};

Loading…
Cancel
Save