diff options
author | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2020-09-25 08:09:12 +0300 |
---|---|---|
committer | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2020-09-28 08:57:38 +0300 |
commit | 188cfb0ad684f21f90ca11cdba1845c4fa97353a (patch) | |
tree | 30a3f4a269ff0b5cf6ab3af4c59d4c79da155dd1 /src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp | |
parent | 03fbc3affe36cec1f12accc3971f24e6291747c6 (diff) |
Prevent duplicates in searchPaths and reverse it
The first 3 paths in the searchPaths are for finding the other
things we need to search for, the last ones are for source paths.
Reversing the order drops the required search count in a usual case
from 4 attempts to 1 or 2.
Task-number: QT3DS-4172
Change-Id: I0d7665566be6b8a9d5e7b918f7596f70126ad958
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Diffstat (limited to 'src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp')
-rw-r--r-- | src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp index 87fe54c..6a0fdff 100644 --- a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp +++ b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp @@ -61,12 +61,14 @@ static const QString QT3DSTUDIO_TAG = QStringLiteral("qt3dstudio"); static QFileInfo matchCaseInsensitiveFile(const QString& file) { - const auto searchFromPaths = [](QString file) -> QFileInfo { + QStringList searchDirectories = QDir::searchPaths(QT3DSTUDIO_TAG); + std::reverse(searchDirectories.begin(), searchDirectories.end()); + + const auto searchFromPaths = [searchDirectories](QString file) -> QFileInfo { QFileInfo fileInfo(file); if (fileInfo.exists()) return fileInfo; - const QStringList searchDirectories = QDir::searchPaths(QT3DSTUDIO_TAG); for (const auto &directoryPath : searchDirectories) { auto path = QDir::cleanPath(directoryPath + '/' + file); QFileInfo info(path); @@ -203,6 +205,7 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK } // First check ktx files if preferKtx is set + QString result; if (preferKtx) { QString ktxSource = path; const bool originalIsKtx = path.endsWith(QLatin1String("ktx"), Qt::CaseInsensitive); @@ -211,7 +214,6 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK ktxSource = ktxSource.left(index); ktxSource.append(QLatin1String(".ktx")); } - QString result; if (checkFileExists(ktxSource, relative, result)) return result; if (originalIsKtx) { @@ -220,7 +222,6 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK } } - QString result; if (checkFileExists(path, relative, result)) return result; |