From d235953a82bf8df5a6011dcf55331e287f0e6e65 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2023 08:00:18 +0100 Subject: [PATCH] QMessageAuthenticationCode: use QCryptographicHashPrivate in finalizeUnchecked() ... basically inlining static QCH::hash(), which, however, accepts only one piece of data, while we have two. Avoids the memory allocation of the QCH d-pointer. The toByteArray() is now the only memory allocation left in finalizeUnchecked(), and will be removed in a subsequent commit. Pick-to: 6.5 Change-Id: I7549d6e1c116a4cdc29dac74b867dfa6647022a0 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcryptographichash.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 2b45033a967..c1a4220ec19 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -1159,11 +1159,12 @@ void QMessageAuthenticationCodePrivate::finalizeUnchecked() for (int i = 0; i < blockSize; ++i) oKeyPad[i] = keyData[i] ^ 0x5c; - QCryptographicHash hash(method); + QCryptographicHashPrivate hash(method); hash.addData(oKeyPad); hash.addData(hashedMessage); + hash.finalizeUnchecked(); - result = hash.result(); + result = hash.resultView().toByteArray(); } /*!