Skip to content

Commit

Permalink
Improve performance by breaking loops on role check failure
Browse files Browse the repository at this point in the history
Added `break` statements to terminate loops early when a selected person cannot perform the specified role. This prevents unnecessary checks and enhances efficiency in role validation.
  • Loading branch information
IllianiCBT committed Jan 10, 2025
1 parent 7553aa4 commit 1545cb6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
for (Person selectedPerson : getSelectedPeople()) {
if (!selectedPerson.canPerformRole(gui.getCampaign().getLocalDate(), role, true)) {
allCanPerform = false;
break;
}
}

Expand All @@ -1519,6 +1520,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
for (Person selectedPerson : getSelectedPeople()) {
if (!selectedPerson.canPerformRole(gui.getCampaign().getLocalDate(), role, false)) {
allCanPerform = false;
break;
}
}

Expand Down

0 comments on commit 1545cb6

Please sign in to comment.