From b6be97f65e139f636e6905cec76f074ce044d6a2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 23 May 2022 14:29:09 +0200 Subject: [PATCH] Don't std::move() trivally-copyable type; it makes no difference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/time/qdatetime.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 4135e602246..189c474bfdd 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); -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); } /*!