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 Pick-to: 6.5 Change-Id: I4d144fcfadc0b8c9ba78d395ff7279b2d5d7b050 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
2449af142f
commit
d32d2137b7
|
|
@ -257,10 +257,12 @@ void QMessageAuthenticationCodePrivate::finalizeUnchecked()
|
|||
QByteArray QMessageAuthenticationCode::hash(const QByteArray &message, const QByteArray &key,
|
||||
QCryptographicHash::Algorithm method)
|
||||
{
|
||||
QMessageAuthenticationCode mac(method);
|
||||
mac.setKey(key);
|
||||
mac.addData(message);
|
||||
return mac.result();
|
||||
QMessageAuthenticationCodePrivate mac(method);
|
||||
mac.key = key;
|
||||
mac.initMessageHash();
|
||||
mac.messageHash.addData(message);
|
||||
mac.finalizeUnchecked();
|
||||
return mac.result;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue