Optimize parameter passing to avoid unnecessary copying
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "../util/stringutil.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
using namespace cmd;
|
||||
|
||||
@@ -156,7 +157,7 @@ public:
|
||||
}
|
||||
return Command(
|
||||
name, std::move(args), std::move(kwargs),
|
||||
std::string(description), executor
|
||||
std::string(description), std::move(executor)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ public:
|
||||
dynamic::Value applyRelative(
|
||||
Argument* arg,
|
||||
dynamic::Value value,
|
||||
dynamic::Value origin
|
||||
const dynamic::Value& origin
|
||||
) {
|
||||
if (origin.index() == 0) {
|
||||
return value;
|
||||
@@ -380,7 +381,7 @@ public:
|
||||
};
|
||||
|
||||
Command Command::create(std::string_view scheme, std::string_view description, executor_func executor) {
|
||||
return CommandParser("<string>", scheme).parseScheme(executor, description);
|
||||
return CommandParser("<string>", scheme).parseScheme(std::move(executor), description);
|
||||
}
|
||||
|
||||
void CommandsRepository::add(
|
||||
@@ -388,7 +389,7 @@ void CommandsRepository::add(
|
||||
std::string_view description,
|
||||
executor_func executor
|
||||
) {
|
||||
Command command = Command::create(scheme, description, executor);
|
||||
Command command = Command::create(scheme, description, std::move(executor));
|
||||
commands[command.getName()] = command;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user