summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-11-26 14:58:12 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-02 01:01:56 +0100
commitf814241abec7cb5317e2c7bf1f9722b2c671a9ba (patch)
tree966767485ae68510d45af53da8b4c9b4dabb3251
parentbda75c81f5648a4f1f2d15b4efaf38a03d5f0d64 (diff)
QVarLengthArray: make static if's constexpr
Cleaner. Probably also more efficient at compile time, who knows? Also more consistent, since _some_ static if's were already constexpr'ed. Change-Id: I9657f7cf2166975f562db52e9f90630aaf412986 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--src/corelib/tools/qvarlengtharray.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 47062fc788..7882efb4c8 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -407,7 +407,7 @@ Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(qsizetype asize)
ptr = reinterpret_cast<T *>(array);
a = Prealloc;
}
- if (QTypeInfo<T>::isComplex) {
+ if constexpr (QTypeInfo<T>::isComplex) {
T *i = end();
while (i != begin())
new (--i) T;
@@ -516,7 +516,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reallocate(qsizetype asi
a = Prealloc;
}
s = 0;
- if (!QTypeInfo<T>::isRelocatable) {
+ if constexpr (!QTypeInfo<T>::isRelocatable) {
QT_TRY {
// move all the old elements
while (size() < copySize) {
@@ -548,7 +548,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reallocate(qsizetype asi
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != data())
free(oldPtr);
- if (QTypeInfo<T>::isComplex) {
+ if constexpr (QTypeInfo<T>::isComplex) {
// call default constructor for new objects (which can throw)
while (size() < asize) {
new (data() + size()) T;
@@ -630,7 +630,7 @@ Q_OUTOFLINE_TEMPLATE auto QVarLengthArray<T, Prealloc>::emplace(const_iterator b
qsizetype offset = qsizetype(before - begin());
if (size() == capacity())
reserve(size() * 2);
- if (!QTypeInfo<T>::isRelocatable) {
+ if constexpr (!QTypeInfo<T>::isRelocatable) {
T *b = begin() + offset;
T *i = end();
T *j = i + 1;
@@ -661,7 +661,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA
if (n != 0) {
const T copy(t); // `t` could alias an element in [begin(), end()[
resize(size() + n);
- if (!QTypeInfo<T>::isRelocatable) {
+ if constexpr (!QTypeInfo<T>::isRelocatable) {
T *b = begin() + offset;
T *j = end();
T *i = j - n;