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