mirror of
https://github.com/tnodir/fort
synced 2024-11-15 11:55:09 +00:00
HostInfoCache: Simplify cost handling.
This commit is contained in:
parent
122f1323ae
commit
10267541b7
@ -5,7 +5,7 @@
|
|||||||
HostInfoCache::HostInfoCache(QObject *parent) :
|
HostInfoCache::HostInfoCache(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_manager(new HostInfoManager(this)),
|
m_manager(new HostInfoManager(this)),
|
||||||
m_cache(1 * 1024 * 1024)
|
m_cache(1000)
|
||||||
{
|
{
|
||||||
connect(m_manager, &HostInfoManager::lookupFinished,
|
connect(m_manager, &HostInfoManager::lookupFinished,
|
||||||
this, &HostInfoCache::handleFinishedLookup);
|
this, &HostInfoCache::handleFinishedLookup);
|
||||||
@ -24,7 +24,7 @@ QString HostInfoCache::hostName(const QString &address)
|
|||||||
if (hostInfo == nullptr) {
|
if (hostInfo == nullptr) {
|
||||||
hostInfo = new HostInfo();
|
hostInfo = new HostInfo();
|
||||||
|
|
||||||
m_cache.insert(address, hostInfo, 4);
|
m_cache.insert(address, hostInfo, 1);
|
||||||
m_manager->lookupHost(address);
|
m_manager->lookupHost(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,11 @@ void HostInfoCache::clear()
|
|||||||
void HostInfoCache::handleFinishedLookup(const QString &address,
|
void HostInfoCache::handleFinishedLookup(const QString &address,
|
||||||
const QString &hostName)
|
const QString &hostName)
|
||||||
{
|
{
|
||||||
HostInfo *hostInfo = m_cache.take(address);
|
HostInfo *hostInfo = m_cache.object(address);
|
||||||
if (hostInfo == nullptr)
|
if (hostInfo == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hostInfo->hostName = hostName;
|
hostInfo->hostName = hostName;
|
||||||
m_cache.insert(address, hostInfo, hostName.size());
|
|
||||||
|
|
||||||
emitCacheChanged();
|
emitCacheChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user