Skip to content
Permalink
Browse files

InputCommon/FunctionExpression: Make MakeFunctionExpression() take a …

…std::string_view

There's nothing within this function that requires a copy of the string
to be made, so we can make use of a non-owning view
  • Loading branch information
lioncash committed Nov 22, 2019
1 parent ddf8abf commit 10fea99d8049d3224f736bcfaa1cf981fa0d14ec
@@ -447,7 +447,7 @@ class PulseExpression : public FunctionExpression
mutable Clock::time_point m_release_time = Clock::now();
};

std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string name)
std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string_view name)
{
if ("not" == name)
return std::make_unique<NotExpression>();
@@ -6,6 +6,7 @@

#include <memory>
#include <string>
#include <string_view>
#include <variant>
#include <vector>

@@ -47,6 +48,6 @@ class FunctionExpression : public Expression
std::vector<std::unique_ptr<Expression>> m_args;
};

std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string name);
std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string_view name);

} // namespace ciface::ExpressionParser

0 comments on commit 10fea99

Please sign in to comment.
You can’t perform that action at this time.