From 1a61b85a2c04d48496a2e83359bf1d65abbc14dc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 30 Nov 2021 15:45:50 +0100 Subject: QVarLengthArray: simplify default ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of calling the QVLA(qsizetype) ctor and letting the optimizer and inliner have a field day on them, simply set the trivial values for a, s, and ptr manually. Mark it as noexcept. Task-number: QTBUG-84785 Change-Id: I011826eacdaf63a4c37b21465e5fe4a6e70a1ab7 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qvarlengtharray.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 3668ebcfc9..18066a80ef 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -63,7 +63,10 @@ class QVarLengthArray static_assert(std::is_nothrow_destructible_v, "Types with throwing destructors are not supported in Qt containers."); public: - QVarLengthArray() : QVarLengthArray(0) {} + QVarLengthArray() noexcept + : a{Prealloc}, s{0}, ptr{reinterpret_cast(array)} + { + } inline explicit QVarLengthArray(qsizetype size); -- cgit v1.2.3