Use cmJoin to accumulate string ranges.
Avoid using the std::accumulate algorithm which is designed for numeric types, not complex types. It introduces unneccessary copies. Initialize variables where they are populated.
This commit is contained in:
parent
4e78ebbdf9
commit
27c6f017a1
|
@ -217,7 +217,6 @@ bool cmFileCommand
|
||||||
bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
||||||
bool append)
|
bool append)
|
||||||
{
|
{
|
||||||
std::string message;
|
|
||||||
std::vector<std::string>::const_iterator i = args.begin();
|
std::vector<std::string>::const_iterator i = args.begin();
|
||||||
|
|
||||||
i++; // Get rid of subcommand
|
i++; // Get rid of subcommand
|
||||||
|
@ -231,10 +230,6 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
for(;i != args.end(); ++i)
|
|
||||||
{
|
|
||||||
message += *i;
|
|
||||||
}
|
|
||||||
if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
|
if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
|
||||||
{
|
{
|
||||||
std::string e
|
std::string e
|
||||||
|
@ -272,6 +267,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
||||||
this->SetError(error);
|
this->SetError(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
std::string message = cmJoin(cmRange(i, args.end()), std::string());
|
||||||
file << message;
|
file << message;
|
||||||
file.close();
|
file.close();
|
||||||
if(mode)
|
if(mode)
|
||||||
|
|
|
@ -20,7 +20,6 @@ bool cmMessageCommand
|
||||||
this->SetError("called with incorrect number of arguments");
|
this->SetError("called with incorrect number of arguments");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string message;
|
|
||||||
std::vector<std::string>::const_iterator i = args.begin();
|
std::vector<std::string>::const_iterator i = args.begin();
|
||||||
|
|
||||||
cmake::MessageType type = cmake::MESSAGE;
|
cmake::MessageType type = cmake::MESSAGE;
|
||||||
|
@ -70,10 +69,7 @@ bool cmMessageCommand
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;i != args.end(); ++i)
|
std::string message = cmJoin(cmRange(i, args.end()), std::string());
|
||||||
{
|
|
||||||
message += *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type != cmake::MESSAGE)
|
if (type != cmake::MESSAGE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue