summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-02-16 23:53:58 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-17 21:23:20 +0100
commitfd96115ae8501c2baf591b821bdf6f7d90b62f55 (patch)
treeca3a0e45a0e998e0c9e54e4ed7e1ef65b353e9e2 /tests
parentfb8be9905d5f3216edc3fbb72b8ce1c380737eac (diff)
QVector: always grow exponentially
For non-movable types (QTypeInfo<T>::isStatic), QVector would grow the array linearly, and defer to qAllocMore otherwise. That property, however, gives no indication as to how the vector will grow. By forcing additional allocations for growing containers of such types, this penalized exactly those objects which are more expensive to move. We now let qAllocMore reign in growth decisions. Change-Id: I843a89dcdc21d09868c6b62a846a7e1e4548e399 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index 159dfbf8dc..4a4f03ee1b 100644
--- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
@@ -308,7 +308,7 @@ void QRawVector<T>::reserve(int asize)
template <typename T>
void QRawVector<T>::resize(int asize)
{ realloc(asize, (asize > m_alloc || (asize < m_size && asize < (m_alloc >> 1)))
- ? QVectorData::grow(sizeOfTypedData(), asize, sizeof(T), QTypeInfo<T>::isStatic)
+ ? QVectorData::grow(sizeOfTypedData(), asize, sizeof(T))
: m_alloc, false); }
template <typename T>
inline void QRawVector<T>::clear()
@@ -510,8 +510,7 @@ void QRawVector<T>::append(const T &t)
{
if (m_size + 1 > m_alloc) {
const T copy(t);
- realloc(m_size, QVectorData::grow(sizeOfTypedData(), m_size + 1, sizeof(T),
- QTypeInfo<T>::isStatic), false);
+ realloc(m_size, QVectorData::grow(sizeOfTypedData(), m_size + 1, sizeof(T)), false);
if (QTypeInfo<T>::isComplex)
new (m_begin + m_size) T(copy);
else
@@ -532,8 +531,7 @@ typename QRawVector<T>::iterator QRawVector<T>::insert(iterator before, size_typ
if (n != 0) {
const T copy(t);
if (m_size + n > m_alloc)
- realloc(m_size, QVectorData::grow(sizeOfTypedData(), m_size + n, sizeof(T),
- QTypeInfo<T>::isStatic), false);
+ realloc(m_size, QVectorData::grow(sizeOfTypedData(), m_size + n, sizeof(T)), false);
if (QTypeInfo<T>::isStatic) {
T *b = m_begin + m_size;
T *i = m_begin + m_size + n;