Command: Use SmallPtrSet for requirements instead of std::set

This commit is contained in:
Peter Johnson
2018-07-28 09:48:10 -07:00
parent eb64ea9fc7
commit fedf828120
4 changed files with 14 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ void CommandGroup::AddSequential(Command* command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
for (auto& requirement : command->GetRequirements()) Requires(requirement);
for (auto&& requirement : command->GetRequirements()) Requires(requirement);
}
void CommandGroup::AddSequential(Command* command, double timeout) {
@@ -47,7 +47,7 @@ void CommandGroup::AddSequential(Command* command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
for (auto& requirement : command->GetRequirements()) Requires(requirement);
for (auto&& requirement : command->GetRequirements()) Requires(requirement);
}
void CommandGroup::AddParallel(Command* command) {
@@ -63,7 +63,7 @@ void CommandGroup::AddParallel(Command* command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
for (auto& requirement : command->GetRequirements()) Requires(requirement);
for (auto&& requirement : command->GetRequirements()) Requires(requirement);
}
void CommandGroup::AddParallel(Command* command, double timeout) {
@@ -84,7 +84,7 @@ void CommandGroup::AddParallel(Command* command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
for (auto& requirement : command->GetRequirements()) Requires(requirement);
for (auto&& requirement : command->GetRequirements()) Requires(requirement);
}
bool CommandGroup::IsInterruptible() const {
@@ -229,7 +229,7 @@ void CommandGroup::CancelConflicts(Command* command) {
Command* child = (*childIter)->m_command;
bool erased = false;
for (auto& requirement : command->GetRequirements()) {
for (auto&& requirement : command->GetRequirements()) {
if (child->DoesRequire(requirement)) {
child->_Cancel();
child->Removed();

View File

@@ -8,7 +8,6 @@
#include "frc/commands/Scheduler.h"
#include <algorithm>
#include <set>
#include <hal/HAL.h>
@@ -100,7 +99,7 @@ void Scheduler::Remove(Command* command) {
if (!m_commands.erase(command)) return;
for (auto& requirement : command->GetRequirements()) {
for (auto&& requirement : command->GetRequirements()) {
requirement->SetCurrentCommand(nullptr);
}
@@ -186,7 +185,7 @@ void Scheduler::ProcessCommandAddition(Command* command) {
auto found = m_commands.find(command);
if (found == m_commands.end()) {
// Check that the requirements can be had
Command::SubsystemSet requirements = command->GetRequirements();
const auto& requirements = command->GetRequirements();
for (const auto& requirement : requirements) {
if (requirement->GetCurrentCommand() != nullptr &&
!requirement->GetCurrentCommand()->IsInterruptible())
@@ -195,7 +194,7 @@ void Scheduler::ProcessCommandAddition(Command* command) {
// Give it the requirements
m_adding = true;
for (auto& requirement : requirements) {
for (auto&& requirement : requirements) {
if (requirement->GetCurrentCommand() != nullptr) {
requirement->GetCurrentCommand()->Cancel();
Remove(requirement->GetCurrentCommand());