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

@@ -8,18 +8,18 @@
#pragma once
#include <memory>
#include <set>
#include <string>
#include <wpi/SmallPtrSet.h>
#include <wpi/Twine.h>
#include "frc/ErrorBase.h"
#include "frc/commands/Subsystem.h"
#include "frc/smartdashboard/SendableBase.h"
namespace frc {
class CommandGroup;
class Subsystem;
/**
* The Command class is at the very core of the entire command framework.
@@ -186,7 +186,7 @@ class Command : public ErrorBase, public SendableBase {
*/
bool DoesRequire(Subsystem* subsystem) const;
typedef std::set<Subsystem*> SubsystemSet;
typedef wpi::SmallPtrSetImpl<Subsystem*> SubsystemSet;
/**
* Returns the requirements (as an std::set of Subsystem pointers) of this
@@ -393,7 +393,7 @@ class Command : public ErrorBase, public SendableBase {
bool m_initialized = false;
// The requirements (or null if no requirements)
SubsystemSet m_requirements;
wpi::SmallPtrSet<Subsystem*, 4> m_requirements;
// Whether or not it is running
bool m_running = false;

View File

@@ -95,7 +95,8 @@ class Scheduler : public ErrorBase, public SendableBase {
void ProcessCommandAddition(Command* command);
Command::SubsystemSet m_subsystems;
typedef std::set<Subsystem*> SubsystemSet;
SubsystemSet m_subsystems;
wpi::mutex m_buttonsMutex;
typedef std::vector<std::unique_ptr<ButtonScheduler>> ButtonVector;
ButtonVector m_buttons;