qt5base-lts/tests/auto/corelib/tools/qcryptographichash
Marc Mutz 27d6314b95 QCryptographicHash: use a std::array to hold result (was: QByteArray)
The maximum size for a hash result is 64 atm. Even if, and esp when,
we'll get to 128 and 256 bytes in the future, there's no reason to use
dynamic memory, because the sizes will always be statically known.

So use, essentially, a std::array<char, 64> to hold the result
internally. Add a bit of convenience API on top to limit impact on the
rest of the code and add a few static_asserts that ensure this is large
enough. Then give users access to the internal buffer by adding
QByteArrayView resultView() const noexcept. The documentation snippet
is taken from QString::data(), suitably adjusted.

Use resultView() in a few places instead of result().

[ChangeLog][QtCore][QCryptographicHash] Changed to use a
statically-sized buffer internally. Added resultView() to access it.

Change-Id: I96c35e55acacbe94529446d720c18325273ffd2f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-15 17:56:23 +02:00
..
data
.gitignore
CMakeLists.txt CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
testdata.qrc
tst_qcryptographichash.cpp QCryptographicHash: use a std::array to hold result (was: QByteArray) 2021-07-15 17:56:23 +02:00