cam: options: Don't implement move semantics for OptionsParser::Options

The compiler creates a move constructor automatically when none is
supplied, and it does the right thing by default in this case. Using
std::move() inside the function prevents the compiler from doing
return value optimization and actually hinders performances. Using
std::move() in the caller is unnecessary, the move constructor is used
automatically by the compiler.

For all these reasons remove the tentative optimization that resulted in
worse performances and worse code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart 2019-01-22 15:31:22 +02:00
parent 29c3b54f0c
commit a22dcaaa78
3 changed files with 2 additions and 15 deletions

View file

@ -33,7 +33,7 @@ static int parseOptions(int argc, char *argv[])
parser.addOption(OptHelp, "Display this help message", "help");
parser.addOption(OptList, "List all cameras", "list");
options = std::move(parser.parse(argc, argv));
options = parser.parse(argc, argv);
if (!options.valid())
return -EINVAL;

View file

@ -102,7 +102,7 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
options.values_[c] = optarg ? optarg : "";
}
return std::move(options);
return options;
}
void OptionsParser::usage()
@ -160,17 +160,6 @@ OptionsParser::Options::Options()
{
}
OptionsParser::Options::Options(Options &&other)
: values_(std::move(other.values_))
{
}
OptionsParser::Options &OptionsParser::Options::operator=(Options &&other)
{
values_ = other.values_;
return *this;
}
bool OptionsParser::Options::valid() const
{
return !values_.empty();

View file

@ -23,8 +23,6 @@ public:
class Options {
public:
Options();
Options(Options &&other);
Options &operator=(Options &&other);
bool valid() const;
bool isSet(int opt) const;