Use switch statement instead of sequence of ifs
This commit is contained in:
parent
93f1678ec6
commit
ba0f841a07
|
@ -120,13 +120,17 @@ static FlakeInput parseFlakeInput(EvalState & state,
|
||||||
expectType(state, nString, *attr.value, *attr.pos);
|
expectType(state, nString, *attr.value, *attr.pos);
|
||||||
input.follows = parseInputPath(attr.value->string.s);
|
input.follows = parseInputPath(attr.value->string.s);
|
||||||
} else {
|
} else {
|
||||||
if (attr.value->type() == nString) {
|
switch (attr.value->type()) {
|
||||||
|
case nString:
|
||||||
attrs.emplace(attr.name, attr.value->string.s);
|
attrs.emplace(attr.name, attr.value->string.s);
|
||||||
} else if (attr.value->type() == nBool) {
|
break;
|
||||||
attrs.emplace(attr.name, Explicit<bool>{ attr.value->boolean });
|
case nBool:
|
||||||
} else if (attr.value->type() == nInt) {
|
attrs.emplace(attr.name, Explicit<bool> { attr.value->boolean });
|
||||||
|
break;
|
||||||
|
case nInt:
|
||||||
attrs.emplace(attr.name, attr.value->integer);
|
attrs.emplace(attr.name, attr.value->integer);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
throw TypeError("flake input attribute '%s' is %s while a string, boolean, or integer is expected",
|
throw TypeError("flake input attribute '%s' is %s while a string, boolean, or integer is expected",
|
||||||
attr.name, showType(*attr.value));
|
attr.name, showType(*attr.value));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue