QStorageInfo/Unix: check the mount point length before isParentOf()

Execute the cheaper test first, so we loop over the entries more
quickly.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd178749a12c966739
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Thiago Macieira 2023-09-22 10:45:41 -07:00
parent da95ad91b3
commit 94df3f8d6b
2 changed files with 2 additions and 2 deletions

View File

@ -143,7 +143,7 @@ void QStorageInfoPrivate::initRootPath()
for (const MountInfo &info : infos) {
// we try to find most suitable entry
qsizetype mpSize = info.mountPoint.size();
if (isParentOf(info.mountPoint, oldRootPath) && maxLength < mpSize) {
if (maxLength < mpSize && isParentOf(info.mountPoint, oldRootPath)) {
bestInfo = &info;
maxLength = mpSize;
}

View File

@ -449,7 +449,7 @@ void QStorageInfoPrivate::initRootPath()
const QString mountDir = it.rootPath();
const QByteArray fsName = it.fileSystemType();
// we try to find most suitable entry
if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.size()) {
if (maxLength < mountDir.size() && isParentOf(mountDir, oldRootPath)) {
maxLength = mountDir.size();
rootPath = mountDir;
device = it.device();