summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <[email protected]>2025-06-20 16:46:38 -0700
committerThiago Macieira <[email protected]>2025-10-18 08:25:21 -0700
commit47c729f7b3102ee22b904dce94b2e6b533d83998 (patch)
treefb1747dd0f28ba96c53268a5d78ba75f374c4aff /src
parent292c6246514eff2c123b4eba2b8f701ce137ba42 (diff)
QArrayDataOps::assign: simplify undoing the prepend optim. for trivials
Since they are trivial, we don't need to loop destroying anything (dead code anyway), so help the compiler out and always store the new capacity begin. This may be storing the value that was already there if no element was removed from the beginning of the list, but it does remove a conditional. Further, this removes the entire looping over the prepend optimization buffer for new elements. We'll fall straight to the main assignment loop. Change-Id: I5338b6a53bffbda17a08fffd1d7eda72d57eff29 Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qarraydataops.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index 4a5926a7056..c6259354de9 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -962,7 +962,12 @@ public:
capacityBegin = Data::dataStart(this->d, alignof(typename Data::AlignmentDummy));
offset = dst - capacityBegin;
}
- if (offset) { // avoids dead stores
+ if constexpr (!QTypeInfo<T>::isComplex) {
+ this->setBegin(capacityBegin); // undo prepend optimization
+ dst = capacityBegin;
+
+ // there's nothing to destroy or overwrite
+ } else if (offset) { // avoids dead stores
T *prependBufferEnd = dst;
this->setBegin(capacityBegin); // undo prepend optimization
dst = capacityBegin;