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
parent
3669ceb779
commit
98e50a18ed
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue