aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cpphoverhandler.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2013-05-15 12:46:08 +0200
committerNikolai Kosjar <nikolai.kosjar@digia.com>2013-06-11 13:03:26 +0200
commit0f2a0d93589f0cd7b3603d05cd94743e133972f9 (patch)
tree7511d425b0616b5d34ae78a528e62bdd29b25921 /src/plugins/cppeditor/cpphoverhandler.cpp
parentf6833168ac9df9c91f1abb25c911bba3aba8446f (diff)
C++: cache results of linksForIdentifier in HelpItem.
The method linksForIdentifier was called at least thrice when generating a single valid tooltip in the C++ editor. Now the cached, and the cache can be "initialised" during construction. This reduces the time spent for creating a tooltip by 30%. Task-number: QTCREATORBUG-8970 Change-Id: I5130b769e977c6ffced1a87715831386ef0d5319 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index 086595b957..cf7d3bab47 100644
--- a/src/plugins/cppeditor/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -77,11 +77,19 @@ void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
const QSharedPointer<CppElement> &cppElement = evaluator.cppElement();
if (!isDiagnosticTooltip())
setToolTip(cppElement->tooltip);
- foreach (const QString &helpId, cppElement->helpIdCandidates) {
- if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) {
+ QStringList candidates = cppElement->helpIdCandidates;
+ candidates.removeDuplicates();
+ HelpManager *hm = HelpManager::instance();
+ foreach (const QString &helpId, candidates) {
+ if (helpId.isEmpty())
+ continue;
+
+ const QMap<QString, QUrl> helpLinks = hm->linksForIdentifier(helpId);
+ if (!helpLinks.isEmpty()) {
setLastHelpItemIdentified(TextEditor::HelpItem(helpId,
cppElement->helpMark,
- cppElement->helpCategory));
+ cppElement->helpCategory,
+ helpLinks));
break;
}
}