Return a string_view instead of a string in the ArgumentAssignable::getValueFor function
This commit is contained in:
parent
1df9b9ed74
commit
5cea9251bd
@ -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());
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user