Simplify conditionals

alloc >= size is an invariant of both QString and QByteArray, unless
string data is immutable (e.g., when using fromRawData()), in which case
alloc will be 0, regardless of size, That's what needs to be checked
here.

Change-Id: Ief9e6a52a1d5ea1941d23ed3c141edfd15d2a6a7
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
João Abecasis 2012-04-04 14:11:14 +02:00 committed by Qt by Nokia
parent 3669ceb779
commit 98e50a18ed
2 changed files with 2 additions and 2 deletions

View File

@ -1433,7 +1433,7 @@ void QByteArray::resize(int size)
if (d->ref.isShared() || size > int(d->alloc)
|| (!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
reallocData(size, true);
if (int(d->alloc) >= size) {
if (d->alloc) {
d->size = size;
d->data()[size] = '\0';
}

View File

@ -1243,7 +1243,7 @@ void QString::resize(int size)
if (d->ref.isShared() || size > int(d->alloc) ||
(!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
reallocData(size, true);
if (int(d->alloc) >= size) {
if (d->alloc) {
d->size = size;
d->data()[size] = '\0';
}