kdecore: use qChecksum() for hashing KConfigIniBackend::BufferFragment objects

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-09-23 10:15:04 +03:00
parent 6428341a30
commit 81018cc798

View file

@ -185,19 +185,9 @@ private:
uint qHash(const KConfigIniBackend::BufferFragment& fragment)
{
const uchar *p = reinterpret_cast<const uchar*>(fragment.constData());
const char *p = fragment.constData();
const int len = fragment.length();
// This algorithm is copied from qhash.cpp (Qt5 version).
// Sadly this code is not accessible from the outside without going through abstraction
// layers. Even QByteArray::fromRawData would do an allocation internally...
uint h = 0;
for (int i = 0; i < len; ++i) {
h = 31 * h + p[i];
}
return h;
return qChecksum(p, len);
}
#endif