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>
This commit is contained in:
Erik Verbruggen
2013-05-15 12:46:08 +02:00
committed by Nikolai Kosjar
parent f6833168ac
commit 0f2a0d9358
3 changed files with 35 additions and 8 deletions

View File

@@ -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;
}
}