mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
remove bogus QByteArray::resize() optimization
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
95d6ba4600
commit
335958f240
1 changed files with 2 additions and 20 deletions
|
@ -1416,26 +1416,8 @@ void QByteArray::resize(int size)
|
|||
if (!d->ref.deref())
|
||||
freeData(d);
|
||||
d = x;
|
||||
} else if (d == &shared_null) {
|
||||
//
|
||||
// Optimize the idiom:
|
||||
// QByteArray a;
|
||||
// a.resize(sz);
|
||||
// ...
|
||||
// which is used in place of the Qt 3 idiom:
|
||||
// QByteArray a(sz);
|
||||
//
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data)+size));
|
||||
Q_CHECK_PTR(x);
|
||||
x->ref = 1;
|
||||
x->alloc = x->size = size;
|
||||
x->data = x->array;
|
||||
x->array[size] = '\0';
|
||||
(void) d->ref.deref(); // cannot be 0, x points to shared_null
|
||||
d = x;
|
||||
} else {
|
||||
if (d->ref != 1 || size != d->size)
|
||||
reallocData(size);
|
||||
} else if (size != d->size) {
|
||||
reallocData(size);
|
||||
d->size = size;
|
||||
if (d->data == d->array) {
|
||||
d->array[size] = '\0';
|
||||
|
|
Loading…
Add table
Reference in a new issue