mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Minor performance improvement of subdir check
* follow T689 * no need to always get and init simulator directory as it will not change
This commit is contained in:
committed by
Mat Sutcliffe
parent
3dde201df0
commit
58b7c875bc
@@ -527,12 +527,21 @@ namespace BlackMisc
|
||||
|
||||
bool CDirectoryUtils::isSubDirectoryOf(const QString &dir1, const QString &dir2)
|
||||
{
|
||||
QDir d1(dir1);
|
||||
if (dir1.isEmpty() || dir2.isEmpty()) { return false; }
|
||||
const QDir d2(dir2);
|
||||
return CDirectoryUtils::isSubDirectoryOf(dir1, d2);
|
||||
}
|
||||
|
||||
bool CDirectoryUtils::isSubDirectoryOf(const QString &dir1, const QDir &dir2)
|
||||
{
|
||||
QDir d1(dir1);
|
||||
do
|
||||
{
|
||||
if (d1 == d2) { return true; }
|
||||
} while (d1.cdUp());
|
||||
if (d1 == dir2) { return true; }
|
||||
}
|
||||
while (d1.cdUp());
|
||||
|
||||
// not found
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user