minor optimization

This commit is contained in:
Roy Qu 2022-12-27 13:26:16 +08:00
parent 988afaac7a
commit 022f32a95f
2 changed files with 13 additions and 19 deletions

View File

@ -93,17 +93,12 @@ void CppTokenizer::dumpTokens(const QString &fileName)
} }
} }
const CppTokenizer::TokenList &CppTokenizer::tokens() const CppTokenizer::PToken &CppTokenizer::operator[](int i) const
{
return mTokenList;
}
CppTokenizer::PToken CppTokenizer::operator[](int i)
{ {
return mTokenList[i]; return mTokenList[i];
} }
int CppTokenizer::tokenCount() int CppTokenizer::tokenCount() const
{ {
return mTokenList.count(); return mTokenList.count();
} }

View File

@ -47,10 +47,9 @@ public:
void clear(); void clear();
void tokenize(const QStringList& buffer); void tokenize(const QStringList& buffer);
void dumpTokens(const QString& fileName); void dumpTokens(const QString& fileName);
const TokenList& tokens(); const PToken& operator[](int i) const;
PToken operator[](int i); int tokenCount() const;
int tokenCount(); static bool isIdentChar(const QChar& ch);
bool isIdentChar(const QChar& ch);
int lambdasCount() const; int lambdasCount() const;
int indexOfFirstLambda() const; int indexOfFirstLambda() const;
void removeFirstLambda(); void removeFirstLambda();
@ -87,15 +86,15 @@ private:
void skipToEOL(); void skipToEOL();
void skipToNextToken(); void skipToNextToken();
bool openFile(const QString& fileName); bool openFile(const QString& fileName);
bool isLetterChar(const QChar& ch); static bool isLetterChar(const QChar& ch);
bool isHexChar(const QChar& ch); static bool isHexChar(const QChar& ch);
bool isDigitChar(const QChar& ch); static bool isDigitChar(const QChar& ch);
bool isSpaceChar(const QChar& ch); static bool isSpaceChar(const QChar& ch);
bool isLineChar(const QChar& ch); static bool isLineChar(const QChar& ch);
bool isBlankChar(const QChar& ch); static bool isBlankChar(const QChar& ch);
bool isOperatorChar(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: private:
QStringList mBuffer; QStringList mBuffer;