summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
authorOleksandr Koval <oleksandr.koval.dev@gmail.com>2020-10-01 11:28:03 (GMT)
committerOleksandr Koval <oleksandr.koval.dev@gmail.com>2020-10-01 11:28:03 (GMT)
commite614528ad1e7d053169535cc32fe566f6eb22d41 (patch)
treefc81ab6b79afc387519d5b97d088ef99a0454567 /Source/cmListFileCache.cxx
parent47b569a85852f716b05ede538e9940392407316c (diff)
downloadCMake-e614528ad1e7d053169535cc32fe566f6eb22d41.zip
CMake-e614528ad1e7d053169535cc32fe566f6eb22d41.tar.gz
CMake-e614528ad1e7d053169535cc32fe566f6eb22d41.tar.bz2
cmListFileCache: Make cmListFileFunction a shared pointer
Passing cmListFileFunction everywhere by-value involves big overhead. Now cmListFileFunction stores std::shared_ptr to the underlying data.
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx23
1 files changed, 9 insertions, 14 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index d678b56..70ef5af 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -15,14 +15,6 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=(
- std::string const& name)
-{
- this->Original = name;
- this->Lower = cmSystemTools::LowerCase(name);
- return *this;
-}
-
struct cmListFileParser
{
cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
@@ -43,7 +35,9 @@ struct cmListFileParser
cmMessenger* Messenger;
const char* FileName;
cmListFileLexer* Lexer;
- cmListFileFunction Function;
+ std::string FunctionName;
+ long FunctionLine;
+ std::vector<cmListFileArgument> FunctionArguments;
enum
{
SeparationOkay,
@@ -141,7 +135,9 @@ bool cmListFileParser::Parse()
if (haveNewline) {
haveNewline = false;
if (this->ParseFunction(token->text, token->line)) {
- this->ListFile->Functions.push_back(this->Function);
+ this->ListFile->Functions.emplace_back(
+ std::move(this->FunctionName), this->FunctionLine,
+ std::move(this->FunctionArguments));
} else {
return false;
}
@@ -200,9 +196,8 @@ bool cmListFile::ParseString(const char* str, const char* virtual_filename,
bool cmListFileParser::ParseFunction(const char* name, long line)
{
// Ininitialize a new function call.
- this->Function = cmListFileFunction();
- this->Function.Name = name;
- this->Function.Line = line;
+ this->FunctionName = name;
+ this->FunctionLine = line;
// Command name has already been parsed. Read the left paren.
cmListFileLexer_Token* token;
@@ -297,7 +292,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
cmListFileArgument::Delimiter delim)
{
- this->Function.Arguments.emplace_back(token->text, delim, token->line);
+ this->FunctionArguments.emplace_back(token->text, delim, token->line);
if (this->Separation == SeparationOkay) {
return true;
}