cache environment queries in QFileSystemEngine::homePath() and QFileSystemEngine::tempPath()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-07-30 21:17:17 -04:00
parent 0c1c5ef96f
commit 7e08917f21

View file

@ -460,7 +460,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
QString QFileSystemEngine::homePath() QString QFileSystemEngine::homePath()
{ {
const QString home = QFile::decodeName(qgetenv("HOME")); static const QString home = QFile::decodeName(qgetenv("HOME"));
if (Q_LIKELY(!home.isEmpty())) if (Q_LIKELY(!home.isEmpty()))
return QDir::cleanPath(home); return QDir::cleanPath(home);
return rootPath(); return rootPath();
@ -473,7 +473,7 @@ QString QFileSystemEngine::rootPath()
QString QFileSystemEngine::tempPath() QString QFileSystemEngine::tempPath()
{ {
const QString temp = QFile::decodeName(qgetenv("TMPDIR")); static const QString temp = QFile::decodeName(qgetenv("TMPDIR"));
if (!temp.isEmpty()) if (!temp.isEmpty())
return QDir::cleanPath(temp); return QDir::cleanPath(temp);
return QLatin1String("/tmp"); return QLatin1String("/tmp");