diff options
author | Orgad Shaneh <[email protected]> | 2014-05-05 17:13:36 +0300 |
---|---|---|
committer | Orgad Shaneh <[email protected]> | 2014-05-13 04:20:27 +0200 |
commit | 0ae69055250612c12b6f8027a04287fad9e4a4a1 (patch) | |
tree | bcd299ac177155c0e83b233441faf6c95240d798 | |
parent | 519913e5990d1668de09705f4c6df66d5e221ad0 (diff) |
CppEditor: Avoid repetitive function calls
Change-Id: I1f3e316336376887ec2e546fcb0cb714c777ee0b
Reviewed-by: Nikolai Kosjar <[email protected]>
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 9 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfollowsymbolundercursor.cpp | 13 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index d77313f1888..cc7e8e82d4a 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -852,10 +852,11 @@ void CPPEditorWidget::markSymbols(const QTextCursor &tc, const SemanticInfo &inf //Other macro uses foreach (const Document::MacroUse &use, info.doc->macroUses()) { - if (use.macro().line() != macro->line() - || use.macro().offset() != macro->offset() - || use.macro().length() != macro->length() - || use.macro().fileName() != macro->fileName()) + const Macro &useMacro = use.macro(); + if (useMacro.line() != macro->line() + || useMacro.offset() != macro->offset() + || useMacro.length() != macro->length() + || useMacro.fileName() != macro->fileName()) continue; QTextCursor cursor(document()); diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index f1ad1f8bf4e..c50bdb6c4d6 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -432,10 +432,11 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & // Move to end of identifier QTextCursor tc = cursor; - QChar ch = m_widget->document()->characterAt(tc.position()); + QTextDocument *document = m_widget->document(); + QChar ch = document->characterAt(tc.position()); while (ch.isLetterOrNumber() || ch == QLatin1Char('_')) { tc.movePosition(QTextCursor::NextCharacter); - ch = m_widget->document()->characterAt(tc.position()); + ch = document->characterAt(tc.position()); } // Try to macth decl/def. For this we need the semantic doc with the AST. @@ -443,9 +444,9 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & && documentFromSemanticInfo->translationUnit() && documentFromSemanticInfo->translationUnit()->ast()) { int pos = tc.position(); - while (m_widget->document()->characterAt(pos).isSpace()) + while (document->characterAt(pos).isSpace()) ++pos; - if (m_widget->document()->characterAt(pos) == QLatin1Char('(')) { + if (document->characterAt(pos) == QLatin1Char('(')) { link = attemptFuncDeclDef(cursor, m_widget, snapshot, documentFromSemanticInfo, symbolFinder); if (link.hasValidLinkText()) @@ -553,7 +554,7 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & if (!recognizedQtMethod) { const QTextBlock block = tc.block(); int pos = cursor.positionInBlock(); - QChar ch = m_widget->document()->characterAt(cursor.position()); + QChar ch = document->characterAt(cursor.position()); if (pos > 0 && !(ch.isLetterOrNumber() || ch == QLatin1Char('_'))) --pos; // positionInBlock points to a delimiter character. const Token tk = SimpleLexer::tokenAt(block.text(), pos, @@ -612,7 +613,7 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & QString expression = expressionUnderCursor(tc); for (int pos = tc.position();; ++pos) { - const QChar ch = m_widget->document()->characterAt(pos); + const QChar ch = document->characterAt(pos); if (ch.isSpace()) continue; if (ch == QLatin1Char('(') && !expression.isEmpty()) { |