From 022f32a95fa1cdb71f99c8d396003b22eae1d8fb Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 27 Dec 2022 13:26:16 +0800 Subject: [PATCH] minor optimization --- RedPandaIDE/parser/cpptokenizer.cpp | 9 ++------- RedPandaIDE/parser/cpptokenizer.h | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index 8db70823..33fc1ae4 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -93,17 +93,12 @@ void CppTokenizer::dumpTokens(const QString &fileName) } } -const CppTokenizer::TokenList &CppTokenizer::tokens() -{ - return mTokenList; -} - -CppTokenizer::PToken CppTokenizer::operator[](int i) +const CppTokenizer::PToken &CppTokenizer::operator[](int i) const { return mTokenList[i]; } -int CppTokenizer::tokenCount() +int CppTokenizer::tokenCount() const { return mTokenList.count(); } diff --git a/RedPandaIDE/parser/cpptokenizer.h b/RedPandaIDE/parser/cpptokenizer.h index dc11162d..4af7f9f0 100644 --- a/RedPandaIDE/parser/cpptokenizer.h +++ b/RedPandaIDE/parser/cpptokenizer.h @@ -47,10 +47,9 @@ public: void clear(); void tokenize(const QStringList& buffer); void dumpTokens(const QString& fileName); - const TokenList& tokens(); - PToken operator[](int i); - int tokenCount(); - bool isIdentChar(const QChar& ch); + const PToken& operator[](int i) const; + int tokenCount() const; + static bool isIdentChar(const QChar& ch); int lambdasCount() const; int indexOfFirstLambda() const; void removeFirstLambda(); @@ -87,15 +86,15 @@ private: void skipToEOL(); void skipToNextToken(); bool openFile(const QString& fileName); - bool isLetterChar(const QChar& ch); - bool isHexChar(const QChar& ch); - bool isDigitChar(const QChar& ch); - bool isSpaceChar(const QChar& ch); - bool isLineChar(const QChar& ch); - bool isBlankChar(const QChar& ch); - bool isOperatorChar(const QChar& ch); + static bool isLetterChar(const QChar& ch); + static bool isHexChar(const QChar& ch); + static bool isDigitChar(const QChar& ch); + static bool isSpaceChar(const QChar& ch); + static bool isLineChar(const QChar& ch); + static bool isBlankChar(const QChar& ch); + static bool isOperatorChar(const QChar& ch); - bool currentWordEquals(QChar* wordStart, QChar *wordEnd, const QString& text); + static bool currentWordEquals(QChar* wordStart, QChar *wordEnd, const QString& text); private: QStringList mBuffer;