Browse Source

Merge topic 'setidentifier_move'

46436581 cmGeneratorExpression: Use std::move to avoid vector copies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1779
pull/320/head
Brad King 8 years ago
committed by Kitware Robot
parent
commit
5c0223886e
  1. 12
      Source/cmGeneratorExpressionEvaluator.h
  2. 7
      Source/cmGeneratorExpressionParser.cxx

12
Source/cmGeneratorExpressionEvaluator.h

@ -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

7
Source/cmGeneratorExpressionParser.cxx

@ -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);
}

Loading…
Cancel
Save