mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 00:11:07 -06:00
cmGeneratorExpression: Use std::move to avoid vector copies
Use move semantics in GeneratorExpressionContent::SetIdentifier and ::SetParameters to avoid vector copies.
This commit is contained in:
committed by
Brad King
parent
31419815aa
commit
46436581c6
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
struct cmGeneratorExpressionContext;
|
||||
@@ -64,17 +65,16 @@ private:
|
||||
struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
|
||||
{
|
||||
GeneratorExpressionContent(const char* startContent, size_t length);
|
||||
void SetIdentifier(
|
||||
std::vector<cmGeneratorExpressionEvaluator*> const& identifier)
|
||||
|
||||
void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier)
|
||||
{
|
||||
this->IdentifierChildren = identifier;
|
||||
this->IdentifierChildren = std::move(identifier);
|
||||
}
|
||||
|
||||
void SetParameters(
|
||||
std::vector<std::vector<cmGeneratorExpressionEvaluator*>> const&
|
||||
parameters)
|
||||
std::vector<std::vector<cmGeneratorExpressionEvaluator*>> parameters)
|
||||
{
|
||||
this->ParamChildren = parameters;
|
||||
this->ParamChildren = std::move(parameters);
|
||||
}
|
||||
|
||||
Type GetType() const override
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <utility>
|
||||
|
||||
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
|
||||
const std::vector<cmGeneratorExpressionToken>& tokens)
|
||||
@@ -92,7 +93,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
||||
assert(this->it != this->Tokens.end());
|
||||
++this->it;
|
||||
--this->NestingLevel;
|
||||
content->SetIdentifier(identifier);
|
||||
content->SetIdentifier(std::move(identifier));
|
||||
result.push_back(content);
|
||||
return;
|
||||
}
|
||||
@@ -198,8 +199,8 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
||||
((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
|
||||
GeneratorExpressionContent* content =
|
||||
new GeneratorExpressionContent(startToken->Content, contentLength);
|
||||
content->SetIdentifier(identifier);
|
||||
content->SetParameters(parameters);
|
||||
content->SetIdentifier(std::move(identifier));
|
||||
content->SetParameters(std::move(parameters));
|
||||
result.push_back(content);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user