ClearMatches: Store match variable names statically
Constructing the names and then turning them into a std::string is non-negligible in performance testing.
This commit is contained in:
parent
f718b30a95
commit
ef62fbad55
|
@ -4332,20 +4332,30 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
|
||||||
return this->QtUiFilesWithOptions;
|
return this->QtUiFilesWithOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string matchVariables[] = {
|
||||||
|
"CMAKE_MATCH_0",
|
||||||
|
"CMAKE_MATCH_1",
|
||||||
|
"CMAKE_MATCH_2",
|
||||||
|
"CMAKE_MATCH_3",
|
||||||
|
"CMAKE_MATCH_4",
|
||||||
|
"CMAKE_MATCH_5",
|
||||||
|
"CMAKE_MATCH_6",
|
||||||
|
"CMAKE_MATCH_7",
|
||||||
|
"CMAKE_MATCH_8",
|
||||||
|
"CMAKE_MATCH_9"
|
||||||
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefile::ClearMatches()
|
void cmMakefile::ClearMatches()
|
||||||
{
|
{
|
||||||
std::stringstream sstr;
|
|
||||||
for (unsigned int i=0; i<this->NumLastMatches; i++)
|
for (unsigned int i=0; i<this->NumLastMatches; i++)
|
||||||
{
|
{
|
||||||
sstr.str("");
|
std::string const& var = matchVariables[i];
|
||||||
sstr << "CMAKE_MATCH_" << i;
|
std::string const& s = this->GetSafeDefinition(var);
|
||||||
std::string const& name = sstr.str();
|
|
||||||
std::string const& s = this->GetSafeDefinition(name);
|
|
||||||
if(!s.empty())
|
if(!s.empty())
|
||||||
{
|
{
|
||||||
this->AddDefinition(name, "");
|
this->AddDefinition(var, "");
|
||||||
this->MarkVariableAsUsed(name);
|
this->MarkVariableAsUsed(var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->NumLastMatches = 0;
|
this->NumLastMatches = 0;
|
||||||
|
@ -4359,10 +4369,9 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
|
||||||
std::string m = re.match(i);
|
std::string m = re.match(i);
|
||||||
if(m.size() > 0)
|
if(m.size() > 0)
|
||||||
{
|
{
|
||||||
char name[128];
|
std::string const& var = matchVariables[i];
|
||||||
sprintf(name, "CMAKE_MATCH_%d", i);
|
this->AddDefinition(var, re.match(i).c_str());
|
||||||
this->AddDefinition(name, re.match(i).c_str());
|
this->MarkVariableAsUsed(var);
|
||||||
this->MarkVariableAsUsed(name);
|
|
||||||
this->NumLastMatches = i + 1;
|
this->NumLastMatches = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue