mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +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,25 +1416,7 @@ void QByteArray::resize(int size)
|
||||||
if (!d->ref.deref())
|
if (!d->ref.deref())
|
||||||
freeData(d);
|
freeData(d);
|
||||||
d = x;
|
d = x;
|
||||||
} else if (d == &shared_null) {
|
} else if (size != d->size) {
|
||||||
//
|
|
||||||
// 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);
|
reallocData(size);
|
||||||
d->size = size;
|
d->size = size;
|
||||||
if (d->data == d->array) {
|
if (d->data == d->array) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue