Commit 6f4d84ae authored by Nicolas Fella's avatar Nicolas Fella Committed by Nate Graham
Browse files

Reduce the number of times we query all mount points

urlIsFastLocalFile is called a lot and every time we query all the mountpoints to
determine whether the file is on a slow one.

We can optimize this based on two assumptions:
- A folder is on only on one mountpoint
- The next call to urlIsFastLocalFile is likely for a file in the same folder

Keep track of the last folder and its mountpoint and only query the mountpoints
when the folder changes
parent 84c6c47f
Pipeline #129470 passed with stage
in 12 minutes and 32 seconds
......@@ -47,15 +47,26 @@ bool urlIsFastLocalFile(const QUrl &url)
return false;
KMountPoint::List list = KMountPoint::currentMountPoints();
KMountPoint::Ptr mountPoint = list.findByPath(url.toLocalFile());
if (!mountPoint) {
// Only query the mountpoint when we haven't queried it for this folder before
static QString lastFolder;
static KMountPoint::Ptr lastMountPoint;
const QString fileName = url.toLocalFile();
QString currentFolder = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
if (currentFolder != lastFolder) {
lastFolder = currentFolder;
KMountPoint::List list = KMountPoint::currentMountPoints();
lastMountPoint = list.findByPath(url.toLocalFile());
if (!lastMountPoint) {
// We couldn't find a mount point for the url. We are probably in a
// chroot. Assume everything is fast then.
return true;
return !mountPoint->probablySlow();
return !lastMountPoint->probablySlow();
bool urlIsDirectory(const QUrl &url)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment