diff options
Diffstat (limited to 'src/corelib/tools/qarraydataops.h')
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index db795e2413..0230677330 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -1497,11 +1497,11 @@ public: Q_ASSERT(b >= this->begin() && b < this->end()); Q_ASSERT(e > this->begin() && e <= this->end()); - // Qt5 QList in erase: try to move less data around - // Now: - const T *begin = this->begin(); - const T *end = this->end(); - if (b - begin < end - e) { + // Comply with std::vector::erase(): erased elements and all after them + // are invalidated. However, erasing from the beginning effectively + // means that all iterators are invalidated. We can use this freedom to + // erase by moving towards the end. + if (b == this->begin()) { Base::erase(GrowsBackwardsTag{}, b, e); } else { Base::erase(GrowsForwardTag{}, b, e); |