From 205824103eb974f59a92a3d8f231f5b189176939 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 5 Jul 2019 17:36:01 +0200 Subject: QVarLengthArray: optimize pop_back() Don't call realloc() with all its machinery when we know exactly what to do: destroy the last element and decrease the size by one. Extend the test, removing the unused Foo class for a new Tracker one. Change-Id: I568eef4f6335669689fb16fd23af92cb4d6464bd Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qvarlengtharray.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools/qvarlengtharray.h') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index ba65ae7ef2..2f62526076 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -112,7 +112,9 @@ public: inline void removeLast() { Q_ASSERT(s > 0); - realloc(s - 1, a); + if (QTypeInfo::isComplex) + ptr[s - 1].~T(); + --s; } inline int size() const { return s; } inline int count() const { return s; } -- cgit v1.2.3