summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/MatchingText.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2010-06-04 09:36:05 +0200
committerErik Verbruggen <erik.verbruggen@nokia.com>2010-06-04 09:36:05 +0200
commitc2393df02332618c8cf6159d9d6f6a40041ced89 (patch)
tree4230c145cc5fa6576310afebe989003151ed38d1 /src/libs/cplusplus/MatchingText.cpp
parent414d9fe3e0fe03f27432b9943e7b2bb5bc2f716c (diff)
downloadqt-creator-c2393df02332618c8cf6159d9d6f6a40041ced89.tar.gz
Introduced a token cache for the C++ editor.
This should speed things up a bit, because before, the line was tokenized at least 3 times.
Diffstat (limited to 'src/libs/cplusplus/MatchingText.cpp')
-rw-r--r--src/libs/cplusplus/MatchingText.cpp8
1 files changed, 5 insertions, 3 deletions
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 <Token.h>
@@ -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))