summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-11-12 16:41:58 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-17 11:47:36 +0100
commit996255baae06310b09892f4376fb8b3227ecbb70 (patch)
tree4f9bc12f20763c9e12865d533853d0a1cdd5bbe4 /src/corelib/text/qbytearray.cpp
parentc0e1a38f69cb3bc43649c7a45896b1fcf807279a (diff)
Fix signature of QArrayDataOps::erase()
Bring it in line with the other methods that also take a pointer and a size. Also use truncate() in removeAll() as that's more efficient for the use case. Change-Id: Ib1073b7c048ceb96fb6391b308ef8feb77896866 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index bc2f73a67d..e1bf2cdc2b 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -2044,7 +2044,9 @@ QByteArray &QByteArray::remove(qsizetype pos, qsizetype len)
if (len <= 0 || pos < 0 || size_t(pos) >= size_t(size()))
return *this;
detach();
- d->erase(d.begin() + pos, d.begin() + qMin(pos + len, size()));
+ if (pos + len > d->size)
+ len = d->size - pos;
+ d->erase(d.begin() + pos, len);
d.data()[d.size] = '\0';
return *this;
}