Coverity fixes.
Primarily using std::move in more places.
This commit is contained in:
@@ -23,9 +23,10 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <scsl/Flag.h>
|
||||
#include <scsl/Flags.h>
|
||||
#include <scsl/StringUtil.h>
|
||||
|
||||
|
||||
@@ -33,7 +34,7 @@ namespace scsl {
|
||||
|
||||
|
||||
static const std::regex isFlag("^--?[a-zA-Z0-9][a-zA-Z0-9-_]*$",
|
||||
std::regex_constants::nosubs);
|
||||
std::regex_constants::nosubs|std::regex_constants::optimize);
|
||||
|
||||
std::string
|
||||
Flags::ParseStatusToString(ParseStatus status)
|
||||
@@ -60,7 +61,7 @@ NewFlag(std::string fName, FlagType fType, std::string fDescription)
|
||||
|
||||
flag->Type = fType;
|
||||
flag->WasSet = false;
|
||||
flag->Name = fName;
|
||||
flag->Name = std::move(fName);
|
||||
flag->Description = fDescription;
|
||||
flag->Value = FlagValue{};
|
||||
|
||||
@@ -69,7 +70,7 @@ NewFlag(std::string fName, FlagType fType, std::string fDescription)
|
||||
|
||||
|
||||
Flags::Flags(std::string fName)
|
||||
: name(fName), description("")
|
||||
: name(std::move(fName)), description("")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ Flags::Register(std::string fName, int defaultValue, std::string fDescription)
|
||||
bool
|
||||
Flags::Register(std::string fName, unsigned int defaultValue, std::string fDescription)
|
||||
{
|
||||
if (!this->Register(fName, FlagType::UnsignedInteger, fDescription)) {
|
||||
if (!this->Register(fName, FlagType::UnsignedInteger, std::move(fDescription))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@ Flags::Register(std::string fName, unsigned int defaultValue, std::string fDescr
|
||||
bool
|
||||
Flags::Register(std::string fName, size_t defaultValue, std::string fDescription)
|
||||
{
|
||||
if (!this->Register(fName, FlagType::SizeT, fDescription)) {
|
||||
if (!this->Register(fName, FlagType::SizeT, std::move(fDescription))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace S {
|
||||
std::vector<std::string>
|
||||
SplitKeyValuePair(std::string line, std::string delimiter)
|
||||
{
|
||||
auto pair = SplitN(line, delimiter, 2);
|
||||
auto pair = SplitN(std::move(line), delimiter, 2);
|
||||
|
||||
if (pair.size() == 0) {
|
||||
return {"", ""};
|
||||
@@ -61,7 +61,7 @@ SplitKeyValuePair(std::string line, char delimiter)
|
||||
{
|
||||
std::string sDelim;
|
||||
|
||||
sDelim.push_back(delimiter);
|
||||
sDelim.push_back(std::move(delimiter));
|
||||
return SplitKeyValuePair(line, sDelim);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ SplitN(std::string s, std::string delim, size_t maxCount)
|
||||
|
||||
|
||||
std::vector<std::string>
|
||||
WrapText(std::string line, size_t lineLength)
|
||||
WrapText(std::string& line, size_t lineLength)
|
||||
{
|
||||
std::vector<std::string> wrapped;
|
||||
auto parts = SplitN(line, " ", 0);
|
||||
|
||||
@@ -35,7 +35,7 @@ Assert(bool condition, std::string message)
|
||||
{
|
||||
#if defined(NDEBUG) || defined(SCSL_NOEXCEPT)
|
||||
if (!condition) {
|
||||
throw AssertionFailed(message);
|
||||
throw AssertionFailed(std::move(message));
|
||||
}
|
||||
#else
|
||||
if (!condition) {
|
||||
|
||||
Reference in New Issue
Block a user