Faster GeoIP lookups.

QCache results in speed decrease.
See https://github.com/qbittorrent/qBittorrent/pull/3488#issuecomment-124731983
This commit is contained in:
sledgehammer999 2015-07-25 01:17:17 +03:00
parent ef5b3b90c3
commit ad7ad8f596
2 changed files with 2 additions and 11 deletions

View file

@ -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()
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();
}

View file

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