From a202bf3621c42a3c2864b7c8ed45205c08d464ca Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 27 Dec 2022 02:43:11 +0200 Subject: [PATCH] implement default QStatInfo constructor and use it as optimization in QFileSystemWatcherPrivate::_q_timeout() Signed-off-by: Ivailo Monev --- src/core/io/qfilesystemwatcher.cpp | 7 +++++-- src/core/kernel/qcore_unix.cpp | 14 ++++++++++++-- src/core/kernel/qcore_unix_p.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/core/io/qfilesystemwatcher.cpp b/src/core/io/qfilesystemwatcher.cpp index 6e9a75a48..bf5e47166 100644 --- a/src/core/io/qfilesystemwatcher.cpp +++ b/src/core/io/qfilesystemwatcher.cpp @@ -94,9 +94,12 @@ void QFileSystemWatcherPrivate::_q_timeout() while (dit.hasNext()) { QHash::iterator x = dit.next(); QString path = x.key(); - QStatInfo fi(path, true); - if (!path.endsWith(QLatin1Char('/'))) + QStatInfo fi; + if (!path.endsWith(QLatin1Char('/'))) { fi = QStatInfo(path + QLatin1Char('/'), true); + } else { + fi = QStatInfo(path, true); + } if (!fi.dirEquals(x.value())) { if (!fi.exists()) { dit.remove(); diff --git a/src/core/kernel/qcore_unix.cpp b/src/core/kernel/qcore_unix.cpp index 2232f8017..860792749 100644 --- a/src/core/kernel/qcore_unix.cpp +++ b/src/core/kernel/qcore_unix.cpp @@ -22,6 +22,7 @@ #include "qcore_unix_p.h" #include "qelapsedtimer.h" #include "qbytearray.h" +#include "qfilesystemmetadata_p.h" #include "qdebug.h" #include @@ -30,10 +31,19 @@ QT_BEGIN_NAMESPACE +QStatInfo::QStatInfo() + : m_mode(0), + m_uid(QFileSystemMetaData::nobodyID), + m_gid(QFileSystemMetaData::nobodyID), + m_mtime(0), + m_size(0) +{ +} + QStatInfo::QStatInfo(const QString &path, const bool listdir) : m_mode(0), - m_uid(-2), - m_gid(-2), + m_uid(QFileSystemMetaData::nobodyID), + m_gid(QFileSystemMetaData::nobodyID), m_mtime(0), m_size(0), m_path(path.toLocal8Bit()) diff --git a/src/core/kernel/qcore_unix_p.h b/src/core/kernel/qcore_unix_p.h index 416656be3..f38e0fe6e 100644 --- a/src/core/kernel/qcore_unix_p.h +++ b/src/core/kernel/qcore_unix_p.h @@ -68,6 +68,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QStatInfo { public: + QStatInfo(); QStatInfo(const QString &path, const bool listdir = false); QStatInfo(const QStatInfo &other); -- 2.11.0