QMessageAuthenticationCode: apply the QCryptographicHash::hash() optimization
... of creating a Private instead of the public class on the stack. This avoids its memory-allocation, as well as the overhead of the mutex in finalize(). Task-number: QTBUG-111347 Change-Id: I4d144fcfadc0b8c9ba78d395ff7279b2d5d7b050 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit d32d2137b7d513f38450d3a5e07a997c3bc90aa1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2f7e6b3448
commit
9a289b7271
@ -257,10 +257,12 @@ void QMessageAuthenticationCodePrivate::finalizeUnchecked()
|
|||||||
QByteArray QMessageAuthenticationCode::hash(const QByteArray &message, const QByteArray &key,
|
QByteArray QMessageAuthenticationCode::hash(const QByteArray &message, const QByteArray &key,
|
||||||
QCryptographicHash::Algorithm method)
|
QCryptographicHash::Algorithm method)
|
||||||
{
|
{
|
||||||
QMessageAuthenticationCode mac(method);
|
QMessageAuthenticationCodePrivate mac(method);
|
||||||
mac.setKey(key);
|
mac.key = key;
|
||||||
mac.addData(message);
|
mac.initMessageHash();
|
||||||
return mac.result();
|
mac.messageHash.addData(message);
|
||||||
|
mac.finalizeUnchecked();
|
||||||
|
return mac.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user