From e42ca194c53b8286447c7750feb8c7497c88e698 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 7 Jun 2010 13:06:21 +0200 Subject: Introduced token caching to prevent repetetive tokenizing. Also removed TokenUnderCursor as it's functionality is in the token cache. Reviewed-by: ckamm --- src/libs/cplusplus/MatchingText.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libs/cplusplus/MatchingText.cpp') diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index b0c5461f24..ed1b8c12b2 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "MatchingText.h" #include "BackwardsScanner.h" +#include "TokenCache.h" #include @@ -75,7 +76,8 @@ static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index) return false; } -MatchingText::MatchingText() +MatchingText::MatchingText(TokenCache *tokenCache) + : _tokenCache(tokenCache) { } bool MatchingText::shouldInsertMatchingText(const QTextCursor &tc) @@ -151,7 +153,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri if (text.isEmpty() || !shouldInsertMatchingText(la)) return QString(); - BackwardsScanner tk(tc, textToProcess.left(*skippedChars), MAX_NUM_LINES); + BackwardsScanner tk(_tokenCache, tc, MAX_NUM_LINES, textToProcess.left(*skippedChars)); const int startToken = tk.startToken(); int index = startToken; @@ -211,7 +213,7 @@ bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const { - BackwardsScanner tk(tc, QString(), MAX_NUM_LINES); + BackwardsScanner tk(_tokenCache, tc, MAX_NUM_LINES); int index = tk.startToken(); if (tk[index - 1].isNot(T_LBRACE)) -- cgit v1.2.1