From 876090aeea80d55093b9f10044c02f2d9d61795e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Nov 2017 17:32:58 +0100 Subject: [PATCH] Remove maximal reallocation size in wxVector This dramatically pessimizes performance for large vector sizes and doesn't actually save that much memory because all intermediate allocations are still being used by the process, so follow stdlibc++ example and just double the allocated buffer size without limit. --- include/wx/vector.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/wx/vector.h b/include/wx/vector.h index 686dc0a587..f07faddfca 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -315,10 +315,8 @@ public: // // NB: casts to size_type are needed to suppress warnings about // mixing enumeral and non-enumeral type in conditional expression - const size_type increment = m_size > 0 - ? m_size < ALLOC_MAX_SIZE - ? m_size - : (size_type)ALLOC_MAX_SIZE + const size_type increment = m_size > ALLOC_INITIAL_SIZE + ? m_size : (size_type)ALLOC_INITIAL_SIZE; if ( m_capacity + increment > n ) n = m_capacity + increment; @@ -491,7 +489,6 @@ public: private: static const size_type ALLOC_INITIAL_SIZE = 16; - static const size_type ALLOC_MAX_SIZE = 4096; void Copy(const wxVector& vb) {