mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Create hash string of Digest on demand
most of the time hash string is not needed and InfoHash is often used as temporaries for torrent searching in handling of torrent alerts. This improves the creation time of Infohash
This commit is contained in:
parent
da12daffee
commit
ad6e2b4b94
@ -50,8 +50,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_dataPtr->valid = true;
|
m_dataPtr->valid = true;
|
||||||
m_dataPtr->nativeDigest = nativeDigest;
|
m_dataPtr->nativeDigest = nativeDigest;
|
||||||
const QByteArray raw = QByteArray::fromRawData(nativeDigest.data(), length());
|
m_dataPtr->hashString.clear(); // hashString is created on demand
|
||||||
m_dataPtr->hashString = QString::fromLatin1(raw.toHex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int length()
|
static constexpr int length()
|
||||||
@ -91,6 +90,12 @@ public:
|
|||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
|
if (m_dataPtr->hashString.isEmpty())
|
||||||
|
{
|
||||||
|
const QByteArray raw = QByteArray::fromRawData(m_dataPtr->nativeDigest.data(), length());
|
||||||
|
const_cast<Digest32 *>(this)->m_dataPtr->hashString = QString::fromLatin1(raw.toHex());
|
||||||
|
}
|
||||||
|
|
||||||
return m_dataPtr->hashString;
|
return m_dataPtr->hashString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user