diff options
author | hjk <hjk@qt.io> | 2019-08-14 10:49:09 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-08-14 09:40:24 +0000 |
commit | e027ed5e964e3e9b4e9a87cf76bcb4f821f616c6 (patch) | |
tree | c82ceb3d7ba982dd935e89cd8765aced871dc0db /src/libs/utils/fileutils.cpp | |
parent | 1ca91b16a04dd12ab2697fc85adac632d12c0c63 (diff) |
Utils: Split FilePath::fileName
Into the regular case, and a fileNameWithPathComponents() function
handling the rarely used case with argument.
This saves a few cycles in the regular case and makes the function
usable by member function pointer in e.g. Utils::transform.
Change-Id: Ic4469198c3f8a44f59e50d70e67b864d876700d5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 50ff572580a..e4d303659f3 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -736,7 +736,13 @@ QString FilePath::toUserOutput() const return m_url.toString(); } -QString FilePath::fileName(int pathComponents) const +QString FilePath::fileName() const +{ + const QChar slash = QLatin1Char('/'); + return m_data.mid(m_data.lastIndexOf(slash) + 1); +} + +QString FilePath::fileNameWithPathComponents(int pathComponents) const { if (pathComponents < 0) return m_data; |