QFileSystemEngine: port a local QSet to QDuplicateTracker
Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: Ife8e09b4a54060ef52c9aac43e400736ea398c29 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7f02abd301
commit
ea7d85457d
@ -45,6 +45,7 @@
|
|||||||
#ifdef QT_BUILD_CORE_LIB
|
#ifdef QT_BUILD_CORE_LIB
|
||||||
#include <QtCore/private/qresource_p.h>
|
#include <QtCore/private/qresource_p.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <QtCore/private/qduplicatetracker_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -64,9 +65,9 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
|
|||||||
QString tmpPath = path;
|
QString tmpPath = path;
|
||||||
int separatorPos = 0;
|
int separatorPos = 0;
|
||||||
QSet<QString> nonSymlinks;
|
QSet<QString> nonSymlinks;
|
||||||
QSet<QString> known;
|
QDuplicateTracker<QString> known;
|
||||||
|
|
||||||
known.insert(path);
|
(void)known.hasSeen(path);
|
||||||
do {
|
do {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (separatorPos == 0) {
|
if (separatorPos == 0) {
|
||||||
@ -94,9 +95,8 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
|
|||||||
tmpPath = QDir::cleanPath(target);
|
tmpPath = QDir::cleanPath(target);
|
||||||
separatorPos = 0;
|
separatorPos = 0;
|
||||||
|
|
||||||
if (known.contains(tmpPath))
|
if (known.hasSeen(tmpPath))
|
||||||
return QString();
|
return QString();
|
||||||
known.insert(tmpPath);
|
|
||||||
} else {
|
} else {
|
||||||
nonSymlinks.insert(prefix);
|
nonSymlinks.insert(prefix);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user