diff options
author | Marc Mutz <marc.mutz@qt.io> | 2021-11-30 15:45:50 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2021-12-01 00:20:25 +0100 |
commit | 1a61b85a2c04d48496a2e83359bf1d65abbc14dc (patch) | |
tree | 5f57091c25bbf6b3cbdcaf2348a7790efb91cb84 /src | |
parent | c8913829001e683a7a14bb342faad4dfd67e4c4b (diff) |
QVarLengthArray: simplify default ctor
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 <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 5 |
1 files changed, 4 insertions, 1 deletions
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<T>, "Types with throwing destructors are not supported in Qt containers."); public: - QVarLengthArray() : QVarLengthArray(0) {} + QVarLengthArray() noexcept + : a{Prealloc}, s{0}, ptr{reinterpret_cast<T *>(array)} + { + } inline explicit QVarLengthArray(qsizetype size); |