Skip to content

Commit

Permalink
Refactor: use switch instead of if.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloodbat committed Sep 30, 2024
1 parent cc92bd9 commit 976a822
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions src/apices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,24 @@ struct Apices : SanguineModule {
parameters[i] = adcValue[i];
}

if (editMode == EDIT_MODE_SPLIT) {
processors[0].CopyParameters(&parameters[0], 2);
processors[1].CopyParameters(&parameters[2], 2);
processors[0].set_control_mode(peaks::CONTROL_MODE_HALF);
processors[1].set_control_mode(peaks::CONTROL_MODE_HALF);
}
else if (editMode == EDIT_MODE_TWIN) {
switch (editMode)
{
case EDIT_MODE_TWIN:
processors[0].CopyParameters(&parameters[0], 4);
processors[1].CopyParameters(&parameters[0], 4);
processors[0].set_control_mode(peaks::CONTROL_MODE_FULL);
processors[1].set_control_mode(peaks::CONTROL_MODE_FULL);
}
else {
break;
case EDIT_MODE_SPLIT:
processors[0].CopyParameters(&parameters[0], 2);
processors[1].CopyParameters(&parameters[2], 2);
processors[0].set_control_mode(peaks::CONTROL_MODE_HALF);
processors[1].set_control_mode(peaks::CONTROL_MODE_HALF);
break;
default:
processors[0].set_control_mode(peaks::CONTROL_MODE_FULL);
processors[1].set_control_mode(peaks::CONTROL_MODE_FULL);
break;
}
}

Expand Down
21 changes: 12 additions & 9 deletions src/mortuus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,21 +424,24 @@ struct Mortuus : SanguineModule {
parameters[i] = adcValue[i];
}

if (editMode == EDIT_MODE_SPLIT) {
processors[0].CopyParameters(&parameters[0], 2);
processors[1].CopyParameters(&parameters[2], 2);
processors[0].set_control_mode(deadman::CONTROL_MODE_HALF);
processors[1].set_control_mode(deadman::CONTROL_MODE_HALF);
}
else if (editMode == EDIT_MODE_TWIN) {
switch (editMode)
{
case EDIT_MODE_TWIN:
processors[0].CopyParameters(&parameters[0], 4);
processors[1].CopyParameters(&parameters[0], 4);
processors[0].set_control_mode(deadman::CONTROL_MODE_FULL);
processors[1].set_control_mode(deadman::CONTROL_MODE_FULL);
}
else {
break;
case EDIT_MODE_SPLIT:
processors[0].CopyParameters(&parameters[0], 2);
processors[1].CopyParameters(&parameters[2], 2);
processors[0].set_control_mode(deadman::CONTROL_MODE_HALF);
processors[1].set_control_mode(deadman::CONTROL_MODE_HALF);
break;
default:
processors[0].set_control_mode(deadman::CONTROL_MODE_FULL);
processors[1].set_control_mode(deadman::CONTROL_MODE_FULL);
break;
}
}

Expand Down

0 comments on commit 976a822

Please sign in to comment.