diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-05 17:36:01 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-14 15:44:22 +0000 |
commit | 205824103eb974f59a92a3d8f231f5b189176939 (patch) | |
tree | 4628976770a0a2c1f3a55fef1f54cbe69472bcf6 /src/corelib | |
parent | 944c5f40b3ca48f89456abeb821b3fe7ba6babf4 (diff) |
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) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 4 |
1 files changed, 3 insertions, 1 deletions
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<T>::isComplex) + ptr[s - 1].~T(); + --s; } inline int size() const { return s; } inline int count() const { return s; } |