forked from qt-creator/qt-creator
AutoTest: Optimize TestCodeParser::scanForTests
In case of loading a Creator project, after the Scanning For Tests finished, the scanForTests() called by TestCodeParser::onFinished() freezed the main thread for about 1 second. In this case requestRemoval() signal was emitted nearly 1000 times. Optimize the internals: 1. Don't emit requestRemoval() for every single file but emit it just once passing a QSet<FilePath> instead. 2. Adapt some other callees and callers to work on QSet<FilePath> instead on a single FilePath. This change constraints the freeze to about 2 ms. Change-Id: If23b85b495c125d82eb3c8b5a6912349df122745 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -389,17 +389,19 @@ QSet<QString> internalTargets(const FilePath &proFile)
|
||||
return result;
|
||||
}
|
||||
|
||||
void QuickTestTreeItem::markForRemovalRecursively(const FilePath &filePath)
|
||||
void QuickTestTreeItem::markForRemovalRecursively(const QSet<FilePath> &filePaths)
|
||||
{
|
||||
TestTreeItem::markForRemovalRecursively(filePath);
|
||||
TestTreeItem::markForRemovalRecursively(filePaths);
|
||||
auto parser = static_cast<QuickTestParser *>(framework()->testParser());
|
||||
const FilePath proFile = parser->projectFileForMainCppFile(filePath);
|
||||
if (!proFile.isEmpty()) {
|
||||
TestTreeItem *root = framework()->rootNode();
|
||||
root->forAllChildItems([proFile](TestTreeItem *it) {
|
||||
if (it->proFile() == proFile)
|
||||
it->markForRemoval(true);
|
||||
});
|
||||
for (const FilePath &filePath : filePaths) {
|
||||
const FilePath proFile = parser->projectFileForMainCppFile(filePath);
|
||||
if (!proFile.isEmpty()) {
|
||||
TestTreeItem *root = framework()->rootNode();
|
||||
root->forAllChildItems([proFile](TestTreeItem *it) {
|
||||
if (it->proFile() == proFile)
|
||||
it->markForRemoval(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user