[Development] Is Qt allowed caching the home dir path?

Jiergir Ogoerg f35f22fan at gmail.com
Sat Oct 26 20:58:10 CEST 2013


Hi,
I noticed that internally QDir::homePath() does quite some extra work:
1) It returns a copy of the home path string (not a const QString&)
2) Each time QDir::homePath() calls QFileSystemEngine::homePath() which
does this:

//START
QString home = QFile::decodeName(qgetenv("HOME"));
if (home.isEmpty())
    home = rootPath();
return QDir::cleanPath(home);
// END

That is, it calls other (sub)functions to perform search, copy and cleaning
up the string which makes me
wonder if it's OK for Qt caching the home dir path as long as the Qt
library runs?

Since getting the home dir is quite a common need for both internal Qt work
and user's
qt apps it would be an easy nice little performance improvement imo.

If it's OK caching, the question also applies to QDir::rootPath() and
QDir::tempPath().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131026/99f00b13/attachment.html>


More information about the Development mailing list