From 61a5d9f94fa56cc02d2fd3744ba4ff6b33d76017 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 27 Dec 2022 14:34:57 +0800 Subject: [PATCH] minor optimization --- RedPandaIDE/parser/cpppreprocessor.cpp | 42 -------------------------- RedPandaIDE/parser/cpppreprocessor.h | 32 +++++++++++++++----- 2 files changed, 25 insertions(+), 49 deletions(-) diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 7dc7f4c7..9aba6b25 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -149,16 +149,6 @@ void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded) addDefineByParts(name, args, value, hardCoded); } -PDefine CppPreprocessor::getDefine(const QString &name) -{ - return mDefines.value(name,PDefine()); -} - -PDefine CppPreprocessor::getHardDefine(const QString &name) -{ - return mHardDefines.value(name,PDefine()); -} - void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal) { mParseSystem = parseSystem; @@ -669,11 +659,6 @@ void CppPreprocessor::removeGCCAttribute(const QString &line, QString &newLine, } } -PParsedFile CppPreprocessor::getInclude(int index) -{ - return mIncludes[index]; -} - void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedText) { if (mIncludes.size()>0) { @@ -802,33 +787,6 @@ void CppPreprocessor::closeInclude() .arg(parsedFile->index+1)); } -bool CppPreprocessor::getCurrentBranch() -{ - if (!mBranchResults.isEmpty()) - return mBranchResults.last(); - else - return true; -} - -void CppPreprocessor::setCurrentBranch(bool value) -{ - mBranchResults.append(value); -} - -void CppPreprocessor::removeCurrentBranch() -{ - if (mBranchResults.size()>0) - mBranchResults.pop_back(); -} - -const QStringList& CppPreprocessor::result() const -{ - -PFileIncludes CppPreprocessor::getFileIncludesEntry(const QString &fileName) -{ - return mIncludesList.value(fileName,PFileIncludes()); -} - void CppPreprocessor::addDefinesInFile(const QString &fileName) { if (mProcessed.contains(fileName)) diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 48efb9a3..da039c6b 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -112,23 +112,41 @@ private: void expandMacro(const QString& line, QString& newLine, QString& word, int& i, int depth); QString removeGCCAttributes(const QString& line); void removeGCCAttribute(const QString&line, QString& newLine, int &i, const QString& word); - PDefine getDefine(const QString& name); + PDefine getDefine(const QString& name) const{ + return mDefines.value(name,PDefine()); + } // current file stuff - PParsedFile getInclude(int index); + PParsedFile getInclude(int index) const { + return mIncludes[index]; + } void openInclude(const QString& fileName, QStringList bufferedText=QStringList()); void closeInclude(); // branch stuff - bool getCurrentBranch(); - void setCurrentBranch(bool value); - void removeCurrentBranch(); + bool getCurrentBranch(){ + if (!mBranchResults.isEmpty()) + return mBranchResults.last(); + else + return true; + } + void setCurrentBranch(bool value){ + mBranchResults.append(value); + } + void removeCurrentBranch(){ + if (mBranchResults.size()>0) + mBranchResults.pop_back(); + }; // include stuff - PFileIncludes getFileIncludesEntry(const QString& FileName); + PFileIncludes getFileIncludesEntry(const QString& fileName){ + return mIncludesList.value(fileName,PFileIncludes()); + } void addDefinesInFile(const QString& fileName); void addDefineByParts(const QString& name, const QString& args, const QString& value, bool hardCoded); void addDefineByLine(const QString& line, bool hardCoded); - PDefine getHardDefine(const QString& name); + PDefine getHardDefine(const QString& name){ + return mHardDefines.value(name,PDefine()); + }; void invalidDefinesInFile(const QString& fileName); void parseArgs(PDefine define);