diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index b075aaba91..1ecb19f135 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2285,7 +2285,7 @@ QByteArray QByteArray::repeated(qsizetype times) const #define REHASH(a) \ if (ol_minus_1 < sizeof(std::size_t) * CHAR_BIT) \ - hashHaystack -= (a) << ol_minus_1; \ + hashHaystack -= std::size_t(a) << ol_minus_1; \ hashHaystack <<= 1 static inline qsizetype findCharHelper(QByteArrayView haystack, qsizetype from, char needle) noexcept diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 1d7e307192..b0834ad762 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -1367,6 +1367,8 @@ public: Q_ASSERT(!this->isShared() || b == e); Q_ASSERT(b <= e); Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; prepareSpaceForAppend(b, e, e - b); // ### perf. loss Base::insert(GrowsForwardTag{}, this->end(), b, e); @@ -1397,6 +1399,8 @@ public: Q_ASSERT(!this->isShared() || b == e); Q_ASSERT(b <= e); Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; prepareSpaceForAppend(b, e, e - b); // ### perf. loss Base::moveAppend(b, e); @@ -1421,6 +1425,8 @@ public: Q_ASSERT(b <= e); Q_ASSERT(e <= where || b > this->end() || where == this->end()); // No overlap or append Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; if (this->size > 0 && where == this->begin()) { // prepend case - special space arrangement prepareSpaceForPrepend(b, e, e - b); // ### perf. loss