From 42ed3b44c8078c207016d8b4478ad35bb66ca5c8 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 18 Apr 2016 15:57:09 +0200 Subject: [PATCH] C++: optimize paragraph insertion. Do not check tokens which are returning the default return value. Do not check for tokens when a previous condition excludes the other token types. Change-Id: Id97aed9d6342c6c12e9b26acdd0a8c4b0bca0868 Reviewed-by: Christian Stenger Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/MatchingText.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index 787d98b99f7..2fdcbab9f69 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -329,11 +329,7 @@ QString MatchingText::insertParagraphSeparator(const QTextCursor &cursor) const Token &token = tk[index - 1]; - if (token.is(T_STRING_LITERAL) && tk[index - 2].is(T_EXTERN)) { - // recognized extern "C" - return QLatin1String("}"); - - } else if (token.is(T_IDENTIFIER)) { + if (token.is(T_IDENTIFIER)) { int i = index - 1; forever { @@ -369,12 +365,6 @@ QString MatchingText::insertParagraphSeparator(const QTextCursor &cursor) --i; } - } - - if (token.is(T_NAMESPACE)) { - // anonymous namespace - return QLatin1String("}"); - } else if (token.is(T_CLASS) || token.is(T_STRUCT) || token.is(T_UNION) || token.is(T_ENUM)) { if (tk[index - 2].is(T_TYPEDEF)) { // recognized: @@ -392,7 +382,7 @@ QString MatchingText::insertParagraphSeparator(const QTextCursor &cursor) const int lparenIndex = tk.startOfMatchingBrace(index); if (lparenIndex == index) { - // found an unmatched brace. We don't really know to do in this case. + // found an unmatched brace. We don't really know what to do in this case. return QString(); }