From de18b3ff370543b5b99bd068b871a2cd677cf9f3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 5 Jul 2021 20:10:07 +0200 Subject: QCryptographicHash: port addData() to QByteArrayView Incl. the static hash() function. Remove the QByteArray versions from the API, but not the ABI. Adapt some callers. [ChangeLog][QtCore][QCryptographicHash] Replaced QByteArray with QByteArrayView in addData() and static hash() functions. Change-Id: Ia0e9bf726276305e05894d323d76a29e985f39eb Reviewed-by: Lars Knoll --- .../tools/qcryptographichash/tst_qcryptographichash.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/auto/corelib/tools') diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 92a2c3516c..a943280996 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -425,7 +425,7 @@ void tst_QCryptographicHash::hashLength() { QFETCH(const QCryptographicHash::Algorithm, algorithm); - QByteArray output = QCryptographicHash::hash(QByteArrayLiteral("test"), algorithm); + QByteArray output = QCryptographicHash::hash("test", algorithm); QCOMPARE(QCryptographicHash::hashLength(algorithm), output.length()); } @@ -480,22 +480,22 @@ void tst_QCryptographicHash::moreThan4GiBOfData() qDebug() << algorithm << "test finished in" << timer.restart() << "ms"; }); - const auto begin = large.data(); - const auto mid = begin + large.size() / 2; - const auto end = begin + large.size(); + const auto view = QByteArrayView{large}; + const auto first = view.first(view.size() / 2); + const auto last = view.sliced(view.size() / 2); QByteArray single; QByteArray chunked; auto t = MaybeThread{[&] { QCryptographicHash h(algorithm); - h.addData(begin, end - begin); + h.addData(view); single = h.result(); }}; { QCryptographicHash h(algorithm); - h.addData(begin, mid - begin); - h.addData(mid, end - mid); + h.addData(first); + h.addData(last); chunked = h.result(); } t.join(); -- cgit v1.2.3