mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 18:09:42 -05: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 <stddef.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct cmGeneratorExpressionContext;
|
struct cmGeneratorExpressionContext;
|
||||||
@@ -64,17 +65,16 @@ private:
|
|||||||
struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
|
struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
|
||||||
{
|
{
|
||||||
GeneratorExpressionContent(const char* startContent, size_t length);
|
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(
|
void SetParameters(
|
||||||
std::vector<std::vector<cmGeneratorExpressionEvaluator*>> const&
|
std::vector<std::vector<cmGeneratorExpressionEvaluator*>> parameters)
|
||||||
parameters)
|
|
||||||
{
|
{
|
||||||
this->ParamChildren = parameters;
|
this->ParamChildren = std::move(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type GetType() const override
|
Type GetType() const override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
|
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
|
||||||
const std::vector<cmGeneratorExpressionToken>& tokens)
|
const std::vector<cmGeneratorExpressionToken>& tokens)
|
||||||
@@ -92,7 +93,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
|||||||
assert(this->it != this->Tokens.end());
|
assert(this->it != this->Tokens.end());
|
||||||
++this->it;
|
++this->it;
|
||||||
--this->NestingLevel;
|
--this->NestingLevel;
|
||||||
content->SetIdentifier(identifier);
|
content->SetIdentifier(std::move(identifier));
|
||||||
result.push_back(content);
|
result.push_back(content);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -198,8 +199,8 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
|||||||
((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
|
((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
|
||||||
GeneratorExpressionContent* content =
|
GeneratorExpressionContent* content =
|
||||||
new GeneratorExpressionContent(startToken->Content, contentLength);
|
new GeneratorExpressionContent(startToken->Content, contentLength);
|
||||||
content->SetIdentifier(identifier);
|
content->SetIdentifier(std::move(identifier));
|
||||||
content->SetParameters(parameters);
|
content->SetParameters(std::move(parameters));
|
||||||
result.push_back(content);
|
result.push_back(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user