Skip to content

Commit

Permalink
switched to overloads to prevent unecessary array allocs on single co…
Browse files Browse the repository at this point in the history
…mmand checks
  • Loading branch information
oh-yes-0-fps committed Sep 19, 2024
1 parent 795829b commit 51ee9b9
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,28 @@ public void cancelAll() {
* scheduled by the scheduler; it will not work on commands inside compositions, as the scheduler
* does not see them.
*
* @param command a single command to check
* @param commands multiple commands to check
* @return whether all of the commands are currently scheduled
*/
public boolean isScheduled(Command command, Command... commands) {
if (commands.length == 0) {
return m_scheduledCommands.contains(command);
} else {
return m_scheduledCommands.contains(command) && m_scheduledCommands.containsAll(Set.of(commands));
public boolean isScheduled(Command... commands) {
for (var cmd : commands) {
if (!isScheduled(cmd)) {
return false;
}
}
return true;
}

/**
* Whether the given commands are running. Note that this only works on commands that are directly
* scheduled by the scheduler; it will not work on commands inside compositions, as the scheduler
* does not see them.
*
* @param command a single command to check
* @return whether all of the commands are currently scheduled
*/
public boolean isScheduled(Command command) {
return m_scheduledCommands.contains(command);
}

/**
Expand Down

0 comments on commit 51ee9b9

Please sign in to comment.