diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-05-23 14:29:09 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-06-08 18:41:01 +0200 |
commit | b6be97f65e139f636e6905cec76f074ce044d6a2 (patch) | |
tree | 93823089979ae1da9157fa66baf817d6071dd641 | |
parent | 140ca89a3c2b8d78889d27217f977cd4de10041b (diff) |
Don't std::move() trivally-copyable type; it makes no difference
CodeChecker says:
std::move of the variable 'parts' of the trivially-copyable type 'QCalendar::YearMonthDay' has no effect; remove std::move()
So don't bother with the move, and remove && from the signature of the
function being called in all four places. Assert that the type *is*
trivially copyable.
Change-Id: I3c07491b4b1dafdf52916e8699561c58c24ee954
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 4135e60224..189c474bfd 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -44,8 +44,9 @@ using namespace QtPrivate::DateTimeConstants; /***************************************************************************** QDate static helper functions *****************************************************************************/ +static_assert(std::is_trivially_copyable_v<QCalendar::YearMonthDay>); -static inline QDate fixedDate(QCalendar::YearMonthDay &&parts, QCalendar cal) +static inline QDate fixedDate(QCalendar::YearMonthDay parts, QCalendar cal) { if ((parts.year < 0 && !cal.isProleptic()) || (parts.year == 0 && !cal.hasYearZero())) return QDate(); @@ -54,7 +55,7 @@ static inline QDate fixedDate(QCalendar::YearMonthDay &&parts, QCalendar cal) return cal.dateFromParts(parts); } -static inline QDate fixedDate(QCalendar::YearMonthDay &&parts) +static inline QDate fixedDate(QCalendar::YearMonthDay parts) { if (parts.year) { parts.day = qMin(parts.day, QGregorianCalendar::monthLength(parts.month, parts.year)); @@ -1299,7 +1300,7 @@ QDate QDate::addMonths(int nmonths, QCalendar cal) const count = (++parts.year || cal.hasYearZero()) ? cal.monthsInYear(parts.year) : 0; } - return fixedDate(std::move(parts), cal); + return fixedDate(parts, cal); } /*! @@ -1331,7 +1332,7 @@ QDate QDate::addMonths(int nmonths) const ++parts.year; } - return fixedDate(std::move(parts)); + return fixedDate(parts); } /*! @@ -1364,7 +1365,7 @@ QDate QDate::addYears(int nyears, QCalendar cal) const if (!cal.hasYearZero() && ((old_y > 0) != (parts.year > 0) || !parts.year)) parts.year += nyears > 0 ? +1 : -1; - return fixedDate(std::move(parts), cal); + return fixedDate(parts, cal); } /*! @@ -1387,7 +1388,7 @@ QDate QDate::addYears(int nyears) const if ((old_y > 0) != (parts.year > 0) || !parts.year) parts.year += nyears > 0 ? +1 : -1; - return fixedDate(std::move(parts)); + return fixedDate(parts); } /*! |