QByteArray::remove(n,n): minor code cleanup
The result of d.begin() is only used in one of the branches, so defining it outside both branches is a bit unmotivated; instead, drag toRemove_start out of the else branch and reuse it in the then branch, too. Amends 358b7a9e747549f85c1d1631dfb21210b52b36f5. Pick-to: 6.9 6.8 6.5 Change-Id: I162d72de7097a1257c8a0a01b69c36fc87466114 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
60af93847e
commit
2831ce613f
@ -2409,13 +2409,12 @@ QByteArray &QByteArray::remove(qsizetype pos, qsizetype len)
|
||||
if (pos + len > d->size)
|
||||
len = d->size - pos;
|
||||
|
||||
auto begin = d.begin();
|
||||
const auto toRemove_start = d.begin() + pos;
|
||||
if (!d->isShared()) {
|
||||
d->erase(begin + pos, len);
|
||||
d->erase(toRemove_start, len);
|
||||
d.data()[d.size] = '\0';
|
||||
} else {
|
||||
QByteArray copy{size() - len, Qt::Uninitialized};
|
||||
const auto toRemove_start = d.begin() + pos;
|
||||
copy.d->copyRanges({{d.begin(), toRemove_start},
|
||||
{toRemove_start + len, d.end()}});
|
||||
swap(copy);
|
||||
|
Loading…
x
Reference in New Issue
Block a user