mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
Ref T184 Cache the result of QHostInfo::localHostName as it is expensive to call.
This commit is contained in:
@@ -14,13 +14,20 @@
|
|||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
|
||||||
|
//! \private
|
||||||
|
const QString &cachedLocalHostName()
|
||||||
|
{
|
||||||
|
static const QString hostName = QHostInfo::localHostName();
|
||||||
|
return hostName;
|
||||||
|
}
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
CIdentifier::CIdentifier(const QString &name)
|
CIdentifier::CIdentifier(const QString &name)
|
||||||
: ITimestampBased(QDateTime::currentMSecsSinceEpoch()),
|
: ITimestampBased(QDateTime::currentMSecsSinceEpoch()),
|
||||||
m_name(name.trimmed()),
|
m_name(name.trimmed()),
|
||||||
m_machineIdBase64(QDBusConnection::localMachineId().toBase64()),
|
m_machineIdBase64(QDBusConnection::localMachineId().toBase64()),
|
||||||
m_machineName(QHostInfo::localHostName()),
|
m_machineName(cachedLocalHostName()),
|
||||||
m_processName(QCoreApplication::applicationName()),
|
m_processName(QCoreApplication::applicationName()),
|
||||||
m_processId(QCoreApplication::applicationPid())
|
m_processId(QCoreApplication::applicationPid())
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
Reference in New Issue
Block a user