mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -52,8 +52,9 @@ Scheduler* Scheduler::GetInstance() {
|
||||
void Scheduler::AddCommand(Command* command) {
|
||||
std::scoped_lock lock(m_impl->additionsMutex);
|
||||
if (std::find(m_impl->additions.begin(), m_impl->additions.end(), command) !=
|
||||
m_impl->additions.end())
|
||||
m_impl->additions.end()) {
|
||||
return;
|
||||
}
|
||||
m_impl->additions.push_back(command);
|
||||
}
|
||||
|
||||
@@ -73,7 +74,9 @@ void Scheduler::RegisterSubsystem(Subsystem* subsystem) {
|
||||
void Scheduler::Run() {
|
||||
// Get button input (going backwards preserves button priority)
|
||||
{
|
||||
if (!m_impl->enabled) return;
|
||||
if (!m_impl->enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock lock(m_impl->buttonsMutex);
|
||||
for (auto& button : m_impl->buttons) {
|
||||
@@ -152,7 +155,9 @@ void Scheduler::ResetAll() {
|
||||
m_impl->commands.clear();
|
||||
}
|
||||
|
||||
void Scheduler::SetEnabled(bool enabled) { m_impl->enabled = enabled; }
|
||||
void Scheduler::SetEnabled(bool enabled) {
|
||||
m_impl->enabled = enabled;
|
||||
}
|
||||
|
||||
void Scheduler::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Scheduler");
|
||||
@@ -163,7 +168,9 @@ void Scheduler::InitSendable(SendableBuilder& builder) {
|
||||
// Get the list of possible commands to cancel
|
||||
auto new_toCancel = cancelEntry.GetValue();
|
||||
wpi::ArrayRef<double> toCancel;
|
||||
if (new_toCancel) toCancel = new_toCancel->GetDoubleArray();
|
||||
if (new_toCancel) {
|
||||
toCancel = new_toCancel->GetDoubleArray();
|
||||
}
|
||||
|
||||
// Cancel commands whose cancel buttons were pressed on the SmartDashboard
|
||||
if (!toCancel.empty()) {
|
||||
@@ -212,7 +219,9 @@ Scheduler::~Scheduler() {
|
||||
}
|
||||
|
||||
void Scheduler::Impl::Remove(Command* command) {
|
||||
if (!commands.erase(command)) return;
|
||||
if (!commands.erase(command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto&& requirement : command->GetRequirements()) {
|
||||
requirement->SetCurrentCommand(nullptr);
|
||||
@@ -222,7 +231,9 @@ void Scheduler::Impl::Remove(Command* command) {
|
||||
}
|
||||
|
||||
void Scheduler::Impl::ProcessCommandAddition(Command* command) {
|
||||
if (command == nullptr) return;
|
||||
if (command == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only add if not already in
|
||||
auto found = commands.find(command);
|
||||
@@ -231,8 +242,9 @@ void Scheduler::Impl::ProcessCommandAddition(Command* command) {
|
||||
const auto& requirements = command->GetRequirements();
|
||||
for (const auto requirement : requirements) {
|
||||
if (requirement->GetCurrentCommand() != nullptr &&
|
||||
!requirement->GetCurrentCommand()->IsInterruptible())
|
||||
!requirement->GetCurrentCommand()->IsInterruptible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Give it the requirements
|
||||
|
||||
Reference in New Issue
Block a user