Debugger: Improve initialization time

* Avoid QFileInfo where not needed
* Use a more accurate filter for QDir::entryList()
* Remove duplicate paths
* Set filters and filter types only once.

Reduces startup time by ~3%

Change-Id: I8896c08da5281e06672b7bdf6e8305ea394122a3
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2014-12-09 22:23:41 +02:00
committed by hjk
parent 0257665901
commit 2022a18f90

View File

@@ -227,7 +227,7 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
}
*/
QFileInfoList suspects;
QList<FileName> suspects;
if (HostOsInfo::isMacHost()) {
QProcess lldbInfo;
@@ -238,20 +238,24 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
lldbInfo.waitForFinished();
} else {
QByteArray lPath = lldbInfo.readAll();
suspects.append(QFileInfo(QString::fromLocal8Bit(lPath.data(), lPath.size() -1)));
const QFileInfo fi(QString::fromLocal8Bit(lPath.data(), lPath.size() -1));
if (fi.exists() && fi.isExecutable() && !fi.isDir())
suspects.append(FileName::fromString(fi.absoluteFilePath()));
}
}
QStringList path = Environment::systemEnvironment().path();
foreach (const QString &base, path) {
QDir dir(base);
path.removeDuplicates();
QDir dir;
dir.setNameFilters(filters);
suspects += dir.entryInfoList();
dir.setFilter(QDir::Files | QDir::Executable);
foreach (const QString &base, path) {
dir.setPath(base);
foreach (const QString &entry, dir.entryList())
suspects.append(FileName::fromString(dir.absoluteFilePath(entry)));
}
foreach (const QFileInfo &fi, suspects) {
if (fi.exists() && fi.isExecutable() && !fi.isDir()) {
FileName command = FileName::fromString(fi.absoluteFilePath());
foreach (const FileName &command, suspects) {
if (findByCommand(command))
continue;
DebuggerItem item;
@@ -260,12 +264,11 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
item.reinitializeFromFile();
//: %1: Debugger engine type (GDB, LLDB, CDB...), %2: Path
item.setDisplayName(tr("System %1 at %2")
.arg(item.engineTypeName()).arg(QDir::toNativeSeparators(fi.absoluteFilePath())));
.arg(item.engineTypeName()).arg(command.toUserOutput()));
item.setAutoDetected(true);
addDebugger(item);
}
}
}
void DebuggerItemManager::readLegacyDebuggers()
{