aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-12-08 17:20:48 +0100
committerhjk <hjk@qt.io>2017-12-15 07:08:05 +0000
commitcc883023090030eb341a11c4d6634ca027f02c65 (patch)
treef5dd463617c340842e1f74440f0caa3a8ea41d3b /src/plugins/cppeditor
parent32762e27e2f4556cd7ed63f78ed3f28695fddccf (diff)
De-emphasize PluginManager::getObjects<Type>()
... by additionally keeping local (currently non-owning) pools per "interesting" type. Current situation: - The global object pool does not scale well for looking up objects, as iteration plus qobject_cast typically iterates over all pooled objects. - User code that can use typed results from the object pool need to have access to the full type definition anyway, i.e. depend on the plugin of the target class anyway. The patch here solves the scaling problem is to have local type-specific pools to which objects register in their constructors and deregister in their destructors. This patch here does *not* change the ownership model of the pooled objects, however, it opens the possibility to change the ownership model per type (e.g. by not putting things into the global pool at all anymore and make the local pool 'owning') and the intent is to handle that in later patchs. Even without the follow-up patches this here is a performance improvement for the cases that access the local pools instead the global one, i.e. "practically all". Change-Id: Ib11a42df2c4ecf5e1155534730083a520dd1995b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r--src/plugins/cppeditor/cppquickfix.h2
-rw-r--r--src/plugins/cppeditor/cppquickfixassistant.cpp9
-rw-r--r--src/plugins/cppeditor/fileandtokenactions_test.cpp41
3 files changed, 23 insertions, 29 deletions
diff --git a/src/plugins/cppeditor/cppquickfix.h b/src/plugins/cppeditor/cppquickfix.h
index 02c63534c7..fba4b733aa 100644
--- a/src/plugins/cppeditor/cppquickfix.h
+++ b/src/plugins/cppeditor/cppquickfix.h
@@ -49,8 +49,6 @@ class CPPEDITOR_EXPORT CppQuickFixFactory: public TextEditor::QuickFixFactory
Q_OBJECT
public:
- CppQuickFixFactory() {}
-
void matchingOperations(const TextEditor::QuickFixInterface &interface,
TextEditor::QuickFixOperations &result);
diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp
index 8ded187d88..349c7111d4 100644
--- a/src/plugins/cppeditor/cppquickfixassistant.cpp
+++ b/src/plugins/cppeditor/cppquickfixassistant.cpp
@@ -34,7 +34,7 @@
#include <cplusplus/ASTPath.h>
-#include <extensionsystem/pluginmanager.h>
+#include <utils/algorithm.h>
#include <utils/qtcassert.h>
using namespace TextEditor;
@@ -59,10 +59,9 @@ IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
QList<QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactories() const
{
- QList<QuickFixFactory *> results;
- foreach (CppQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<CppQuickFixFactory>())
- results.append(f);
- return results;
+ return Utils::filtered(QuickFixFactory::allQuickFixFactories(), [](QuickFixFactory *f) {
+ return qobject_cast<CppQuickFixFactory *>(f) != nullptr;
+ });
}
// --------------------------
diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp
index 463172d45b..21b11c7524 100644
--- a/src/plugins/cppeditor/fileandtokenactions_test.cpp
+++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp
@@ -41,7 +41,6 @@
#include <projectexplorer/projectexplorer.h>
#include <texteditor/textdocument.h>
-#include <extensionsystem/pluginmanager.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/TranslationUnit.h>
#include <utils/algorithm.h>
@@ -448,33 +447,31 @@ void RunAllQuickFixesTokenAction::run(CppEditorWidget *editorWidget)
// Calling editorWidget->invokeAssist(QuickFix) would be not enough
// since we also want to execute the ones that match.
- const QList<CppQuickFixFactory *> quickFixFactories
- = ExtensionSystem::PluginManager::getObjects<CppQuickFixFactory>();
- QVERIFY(!quickFixFactories.isEmpty());
-
CppQuickFixInterface qfi(editorWidget, ExplicitlyInvoked);
// This guard is important since the Quick Fixes expect to get a non-empty path().
if (qfi.path().isEmpty())
return;
- foreach (CppQuickFixFactory *quickFixFactory, quickFixFactories) {
- QuickFixOperations operations;
- // Some Quick Fixes pop up a dialog and are therefore inappropriate for this test.
- // Where possible, use a guiless version of the factory.
- if (qobject_cast<InsertVirtualMethods *>(quickFixFactory)) {
- QScopedPointer<CppQuickFixFactory> factoryProducingGuiLessOperations;
- factoryProducingGuiLessOperations.reset(InsertVirtualMethods::createTestFactory());
- factoryProducingGuiLessOperations->match(qfi, operations);
- } else {
- quickFixFactory->match(qfi, operations);
- }
+ for (QuickFixFactory *quickFixFactory : QuickFixFactory::allQuickFixFactories()) {
+ if (auto cppQuickFixFactory = qobject_cast<CppQuickFixFactory *>(quickFixFactory)) {
+ QuickFixOperations operations;
+ // Some Quick Fixes pop up a dialog and are therefore inappropriate for this test.
+ // Where possible, use a guiless version of the factory.
+ if (qobject_cast<InsertVirtualMethods *>(cppQuickFixFactory)) {
+ QScopedPointer<CppQuickFixFactory> factoryProducingGuiLessOperations;
+ factoryProducingGuiLessOperations.reset(InsertVirtualMethods::createTestFactory());
+ factoryProducingGuiLessOperations->match(qfi, operations);
+ } else {
+ cppQuickFixFactory->match(qfi, operations);
+ }
- foreach (QuickFixOperation::Ptr operation, operations) {
- qDebug() << " -- Performing Quick Fix" << operation->description();
- operation->perform();
- TestActionsTestCase::escape();
- TestActionsTestCase::undoChangesInAllEditorWidgets();
- QApplication::processEvents();
+ foreach (QuickFixOperation::Ptr operation, operations) {
+ qDebug() << " -- Performing Quick Fix" << operation->description();
+ operation->perform();
+ TestActionsTestCase::escape();
+ TestActionsTestCase::undoChangesInAllEditorWidgets();
+ QApplication::processEvents();
+ }
}
}
}