Skip to content

Commit

Permalink
QDateTime::fromStdTimePoint: remove an unnecessary time_point_cast
Browse files Browse the repository at this point in the history
The constraint now checks that the result of the clock_cast has a
duration which is convertible to milliseconds, so just do the
implicit conversion, without any cast for the duration.

Task-number: QTBUG-125587
Change-Id: Id2c8232d756318c3e4d33cd7e1556773961a9dba
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
dangelog committed Jun 2, 2024
1 parent 9ec1de2 commit 48ab909
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/corelib/time/qdatetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,9 @@ class Q_CORE_EXPORT QDateTime
>;
}
{
const auto sysTime = std::chrono::clock_cast<std::chrono::system_clock>(time);
// clock_cast can change the duration, so convert it again to milliseconds
const auto timeInMSec = std::chrono::time_point_cast<std::chrono::milliseconds>(sysTime);
return fromStdTimePoint(timeInMSec);
using namespace std::chrono;
const sys_time<milliseconds> sysTime = clock_cast<system_clock>(time);
return fromStdTimePoint(sysTime);
}
#endif // __cpp_concepts

Expand Down

0 comments on commit 48ab909

Please sign in to comment.