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:
Peter Johnson
2020-12-28 12:58:06 -08:00
committed by GitHub
parent 0291a3ff56
commit 2aed432b4b
634 changed files with 10716 additions and 3938 deletions

View File

@@ -63,7 +63,9 @@ void AddressableLEDsModel::Update() {
if (!model) {
model = std::make_unique<AddressableLEDModel>(i);
}
if (model) model->Update();
if (model) {
model->Update();
}
} else {
model.reset();
}
@@ -72,7 +74,9 @@ void AddressableLEDsModel::Update() {
bool AddressableLEDsModel::Exists() {
for (auto&& model : m_models) {
if (model && model->Exists()) return true;
if (model && model->Exists()) {
return true;
}
}
return false;
}
@@ -80,14 +84,18 @@ bool AddressableLEDsModel::Exists() {
void AddressableLEDsModel::ForEachLEDDisplay(
wpi::function_ref<void(glass::LEDDisplayModel& model, int index)> func) {
for (int i = 0; i < static_cast<int>(m_models.size()); ++i) {
if (m_models[i]) func(*m_models[i], i);
if (m_models[i]) {
func(*m_models[i], i);
}
}
}
static bool AddressableLEDsExists() {
static const int numLED = HAL_GetNumAddressableLEDs();
for (int i = 0; i < numLED; ++i) {
if (HALSIM_GetAddressableLEDInitialized(i)) return true;
if (HALSIM_GetAddressableLEDInitialized(i)) {
return true;
}
}
return false;
}