Browse Source

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
adaptive-webui-19844
Prince Gupta 3 years ago
parent
commit
ad6e2b4b94
  1. 9
      src/base/digest32.h

9
src/base/digest32.h

@ -50,8 +50,7 @@ public: @@ -50,8 +50,7 @@ public:
{
m_dataPtr->valid = true;
m_dataPtr->nativeDigest = nativeDigest;
const QByteArray raw = QByteArray::fromRawData(nativeDigest.data(), length());
m_dataPtr->hashString = QString::fromLatin1(raw.toHex());
m_dataPtr->hashString.clear(); // hashString is created on demand
}
static constexpr int length()
@ -91,6 +90,12 @@ public: @@ -91,6 +90,12 @@ public:
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;
}

Loading…
Cancel
Save