diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2012-01-10 16:03:30 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-11 17:17:29 +0100 |
commit | 2c52e9a5c1d6ef6cbf4577430e14027375465c96 (patch) | |
tree | 1c34587e7627ad43bfa2efaa4cc085b18d9d30e7 /tests/auto/corelib/tools/qarraydata | |
parent | 5a92bc9760eb0bff73ac312850f81059f05eb5a9 (diff) |
Expand if condition for readability
Change-Id: I5057c236457587ad03b55019cb340cf59d9ecdb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qarraydata')
-rw-r--r-- | tests/auto/corelib/tools/qarraydata/simplevector.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h index 54c5fd2f61..a1eb2dac48 100644 --- a/tests/auto/corelib/tools/qarraydata/simplevector.h +++ b/tests/auto/corelib/tools/qarraydata/simplevector.h @@ -139,15 +139,22 @@ public: void reserve(size_t n) { - if (n > capacity() - || (n - && !d->capacityReserved - && (d->ref.isShared() || (d->capacityReserved = 1, false)))) { - SimpleVector detached(Data::allocate(n, - d->detachFlags() | Data::CapacityReserved)); - detached.d->copyAppend(constBegin(), constEnd()); - detached.swap(*this); + if (n == 0) + return; + + if (n <= capacity()) { + if (d->capacityReserved) + return; + if (!d->ref.isShared()) { + d->capacityReserved = 1; + return; + } } + + SimpleVector detached(Data::allocate(n, + d->detachFlags() | Data::CapacityReserved)); + detached.d->copyAppend(constBegin(), constEnd()); + detached.swap(*this); } void prepend(const_iterator first, const_iterator last) |