diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2022-10-06 19:10:33 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2022-12-23 15:13:14 +0200 |
commit | 2fc50a914d4b972e2c1b8f78f176c86ceece1111 (patch) | |
tree | a41eb70970d65bf01109133e83c76ef6113921b5 /src/corelib/io | |
parent | 605829546fdfa691e256f0119a68b6cb0e9f14c7 (diff) |
QDir: when sorting by time, get last modification times as UTC directly
PASS : tst_QDir_10000::sorted_byTime()
RESULT : tst_QDir_10000::sorted_byTime():
345 msecs per iteration (total: 345, iterations: 1)
PASS : tst_QDir_10000::sorted_byTime()
RESULT : tst_QDir_10000::sorted_byTime():
0.000015 msecs per iteration (total: 54, iterations: 262144)
Change-Id: I7976c8668aa821d2b7ed3f774f29bdf1ba4a99d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdir.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3e42ad0979..547512bf59 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -219,16 +219,8 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt switch (sortBy) { case QDir::Time: { - QDateTime firstModified = f1->item.lastModified(); - QDateTime secondModified = f2->item.lastModified(); - - // QDateTime by default will do all sorts of conversions on these to - // find timezones, which is incredibly expensive. As we aren't - // presenting these to the user, we don't care (at all) about the - // local timezone, so force them to UTC to avoid that conversion. - firstModified.setTimeZone(QTimeZone::UTC); - secondModified.setTimeZone(QTimeZone::UTC); - + const QDateTime firstModified = f1->item.lastModified(QTimeZone::UTC); + const QDateTime secondModified = f2->item.lastModified(QTimeZone::UTC); r = firstModified.msecsTo(secondModified); break; } |