summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvarlengtharray.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-05-12 12:31:17 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-05-13 05:14:49 +0000
commit11791e2a50417661679f84aeae21ce959cab638f (patch)
treec805229d09ea0f26ca9c924ae0f0ac3bf2565f1a /src/corelib/tools/qvarlengtharray.h
parent250f5f4a11ed231dfcbd217ab2d2ce13ab2f9105 (diff)
QVarLengthArray: Move unique_ptr<void, free_deleter> to QVLABaseBase
This avoids repeated re-instantiations of unique_ptr with local deleters, removing that instantiation from the top of the list in Clang -ftime-trace QtWidgets builds: **** Templates that took longest to instantiate: 2627 ms: std::__1::unique_ptr<void, free_deleter> (835 times, avg 3 ms) Amends e297e80fd0ec6ce4c97ee1b40426c76377b45ecc. Pick-to: 6.3 Task-number: QTBUG-97601 Task-number: QTBUG-99039 Change-Id: I1281f6cf9248a3796d9dfdc653f19f5a67dc3bda Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r--src/corelib/tools/qvarlengtharray.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 5898e486f9..261cdcb5cd 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -96,6 +96,11 @@ protected:
Q_ASSERT(n <= size() - pos);
}
+ struct free_deleter {
+ void operator()(void *p) const noexcept { free(p); }
+ };
+ using malloced_ptr = std::unique_ptr<void, free_deleter>;
+
public:
using size_type = qsizetype;
@@ -748,10 +753,7 @@ Q_OUTOFLINE_TEMPLATE void QVLABase<T>::reallocate_impl(qsizetype prealloc, void
Q_ASSUME(copySize >= 0);
if (aalloc != capacity()) {
- struct free_deleter {
- void operator()(void *p) const noexcept { free(p); }
- };
- std::unique_ptr<void, free_deleter> guard;
+ QVLABaseBase::malloced_ptr guard;
void *newPtr;
qsizetype newA;
if (aalloc > prealloc) {