From 9fd34288efdbb5c77d002408dd83bccbd654292f Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 26 Jun 2012 10:01:39 +1000 Subject: [PATCH] Remove default allocation size for PODVector. The default increment was 1024, which can waste memory. Remove the default value so that clients must explicitly set the allocation increment. The original bug is no longer relevant, as capture properties are now stored in a linked list rather than a POD vector. Task-number: QTBUG-20285 Change-Id: Iadb0b40af19fed36ccc05249461acc7e870dcbc3 Reviewed-by: Chris Adams --- src/qml/qml/ftw/qpodvector_p.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h index c966926..d7f51b4 100644 --- a/src/qml/qml/ftw/qpodvector_p.h +++ b/src/qml/qml/ftw/qpodvector_p.h @@ -58,13 +58,13 @@ QT_BEGIN_NAMESPACE -template -class QPODVector +template +class QPODVector { public: QPODVector() : m_count(0), m_capacity(0), m_data(0) {} - ~QPODVector() { if (m_data) ::free(m_data); } + ~QPODVector() { if (m_data) ::free(m_data); } const T &at(int idx) const { return m_data[idx]; @@ -109,8 +109,8 @@ public: int newSize = m_count + count; reserve(newSize); int moveCount = m_count - idx; - if (moveCount) - ::memmove(m_data + idx + count, m_data + idx, + if (moveCount) + ::memmove(m_data + idx + count, m_data + idx, moveCount * sizeof(T)); m_count = newSize; } @@ -118,7 +118,7 @@ public: void remove(int idx, int count = 1) { int moveCount = m_count - (idx + count); if (moveCount) - ::memmove(m_data + idx, m_data + idx + count, + ::memmove(m_data + idx, m_data + idx + count, moveCount * sizeof(T)); m_count -= count; } -- 2.7.4