Skip to content

Commit

Permalink
Reorganize four-way if-elsif-elsif-elsif as nested if-elses
Browse files Browse the repository at this point in the history
  • Loading branch information
mjdominus committed Jun 4, 2024
1 parent ead1013 commit 3cf3f84
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions Parser/action_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,25 +543,30 @@ _make_posargs(Parser *p,
asdl_arg_seq *plain_names,
asdl_seq *names_with_default,
asdl_arg_seq **posargs) {
if (plain_names != NULL && names_with_default != NULL) {
asdl_arg_seq *names_with_default_names = _get_names(p, names_with_default);
if (!names_with_default_names) {
return -1;

if (names_with_default != NULL) {
if (plain_names != NULL) {
asdl_arg_seq *names_with_default_names = _get_names(p, names_with_default);
if (!names_with_default_names) {
return -1;
}
*posargs = (asdl_arg_seq*)_PyPegen_join_sequences(
p,(asdl_seq*)plain_names, (asdl_seq*)names_with_default_names);
}
else {
*posargs = _get_names(p, names_with_default);
}
*posargs = (asdl_arg_seq*)_PyPegen_join_sequences(
p,(asdl_seq*)plain_names, (asdl_seq*)names_with_default_names);
}
else if (plain_names == NULL && names_with_default != NULL) {
*posargs = _get_names(p, names_with_default);
}
else if (plain_names != NULL && names_with_default == NULL) {
// With the current grammar, we never get here.
// If that has changed, remove the assert, and test thoroughly.
assert(0);
*posargs = plain_names;
}
else {
*posargs = _Py_asdl_arg_seq_new(0, p->arena);
if (plain_names != NULL) {
// With the current grammar, we never get here.
// If that has changed, remove the assert, and test thoroughly.
assert(0);
*posargs = plain_names;
}
else {
*posargs = _Py_asdl_arg_seq_new(0, p->arena);
}
}
return *posargs == NULL ? -1 : 0;
}
Expand Down

0 comments on commit 3cf3f84

Please sign in to comment.