Return a string_view instead of a string in the ArgumentAssignable::getValueFor function

This commit is contained in:
Username404 2021-10-03 12:20:59 +02:00
parent 1df9b9ed74
commit 5cea9251bd
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 3 additions and 3 deletions

View File

@ -25,9 +25,9 @@ public:
class ArgumentAssignable: public Argument {
vector<string_view> values;
public:
static string getValueFor(const string& str) {
static string_view getValueFor(const string_view& str) {
unsigned long definePos = str.find_last_of('=') + 1;
return str.size() > definePos ? str.substr(definePos) : string();
return str.size() > definePos ? str.substr(definePos) : string_view();
}
ArgumentAssignable(string name, const span<string_view>& possibleValues): Argument(move(name)), values() {
values.reserve(possibleValues.size());

View File

@ -22,7 +22,7 @@ int main(int argc, char* argv[]) {
if ((argc == 2) && (currentArg == Argument("version"))) { cout << Yerbacon::getVersion() << endl; exit(EXIT_SUCCESS); }
else if (currentArg == ArgumentShort("printresult")) printResult = true;
else if (currentArg == ArgumentAssignable("target")) {
const string value = ArgumentAssignable::getValueFor(currentArg.data());
const string_view value = ArgumentAssignable::getValueFor(currentArg);
if (!value.empty()) (target = '.') += value;
}
else if (currentArg == Argument("parallel")) parallel = true;