QStandardPaths: use qTokenizer
Avoids allocating memory for the array. Change-Id: I425235b948609e5f0ffcfffd0f93375a224e5bcb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 403a47cfd571c9954e91234084c6994901939326) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
96fe113608
commit
b39b3551b7
@ -522,11 +522,10 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove trailing slashes, which occur on Windows.
|
// Remove trailing slashes, which occur on Windows.
|
||||||
const QStringList rawPaths = pEnv.split(
|
searchPaths.reserve(pEnv.count(QDir::listSeparator()));
|
||||||
QDir::listSeparator(), Qt::SkipEmptyParts);
|
auto tokenizer = qTokenize(pEnv, QDir::listSeparator(), Qt::SkipEmptyParts);
|
||||||
searchPaths.reserve(rawPaths.size());
|
for (QStringView rawPath : tokenizer) {
|
||||||
for (const QString &rawPath : rawPaths) {
|
QString cleanPath = QDir::cleanPath(rawPath.toString());
|
||||||
QString cleanPath = QDir::cleanPath(rawPath);
|
|
||||||
if (cleanPath.size() > 1 && cleanPath.endsWith(u'/'))
|
if (cleanPath.size() > 1 && cleanPath.endsWith(u'/'))
|
||||||
cleanPath.truncate(cleanPath.size() - 1);
|
cleanPath.truncate(cleanPath.size() - 1);
|
||||||
searchPaths.push_back(cleanPath);
|
searchPaths.push_back(cleanPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user