QDateTime: refactor an if-else

Change-Id: I1d1bd6d0e819e525b03898d43a2a683ee617a3ed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Ahmad Samir 2023-08-18 21:31:58 +03:00
parent 38429c16b5
commit 5d1e4567f9

View File

@ -4387,14 +4387,8 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const
dt.d.detach(); dt.d.detach();
dt.d->m_status &= ~QDateTimePrivate::ValidityMask; dt.d->m_status &= ~QDateTimePrivate::ValidityMask;
} }
} else if (d.isShort()) { } else if (d.isShort() && msecsCanBeSmall(msecs)) {
// need to check if we need to enlarge first dt.d.data.msecs = qintptr(msecs);
if (msecsCanBeSmall(msecs)) {
dt.d.data.msecs = qintptr(msecs);
} else {
dt.d.detach();
dt.d->m_msecs = msecs;
}
} else { } else {
dt.d.detach(); dt.d.detach();
dt.d->m_msecs = msecs; dt.d->m_msecs = msecs;