From 8948f5cc78e4151e04395375269b9efbf9a3bac7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Aug 2021 12:09:36 +0200 Subject: [PATCH] QStandardPaths/Unix: use QStringTokenizer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids having to allocate storage to hold the parts. Since the startsWith('/') will fail for empty parts, remove the SkipEmptyParts so we don't check for emptiness twice. Change-Id: Id33a52d5fbd29f7a9d4ead758729195bb201a369 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/io/qstandardpaths_unix.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 09f6c9d639..fa35265257 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -354,10 +354,8 @@ static QStringList xdgDataDirs() dirs.append(QString::fromLatin1("/usr/local/share")); dirs.append(QString::fromLatin1("/usr/share")); } else { - const auto parts = QStringView{xdgDataDirsEnv}.split(QLatin1Char(':'), Qt::SkipEmptyParts); - // Normalize paths, skip relative paths - for (const auto &dir : parts) { + for (const auto dir : qTokenize(xdgDataDirsEnv, u':')) { if (dir.startsWith(QLatin1Char('/'))) dirs.push_back(QDir::cleanPath(dir.toString())); }