mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +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:
@@ -14,7 +14,9 @@ DataSource::DataSource(const wpi::Twine& id) : m_id{id.str()} {
|
||||
auto it = gContext->sources.try_emplace(m_id, this);
|
||||
auto& srcName = it.first->getValue();
|
||||
m_name = srcName.name.get();
|
||||
if (!srcName.source) srcName.source = this;
|
||||
if (!srcName.source) {
|
||||
srcName.source = this;
|
||||
}
|
||||
sourceCreated(m_id.c_str(), this);
|
||||
}
|
||||
|
||||
@@ -26,18 +28,30 @@ DataSource::DataSource(const wpi::Twine& id, int index, int index2)
|
||||
wpi::Twine(index2) + wpi::Twine(']')} {}
|
||||
|
||||
DataSource::~DataSource() {
|
||||
if (!gContext) return;
|
||||
if (!gContext) {
|
||||
return;
|
||||
}
|
||||
auto it = gContext->sources.find(m_id);
|
||||
if (it == gContext->sources.end()) return;
|
||||
if (it == gContext->sources.end()) {
|
||||
return;
|
||||
}
|
||||
auto& srcName = it->getValue();
|
||||
if (srcName.source == this) srcName.source = nullptr;
|
||||
if (srcName.source == this) {
|
||||
srcName.source = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DataSource::SetName(const wpi::Twine& name) { m_name->SetName(name); }
|
||||
void DataSource::SetName(const wpi::Twine& name) {
|
||||
m_name->SetName(name);
|
||||
}
|
||||
|
||||
const char* DataSource::GetName() const { return m_name->GetName(); }
|
||||
const char* DataSource::GetName() const {
|
||||
return m_name->GetName();
|
||||
}
|
||||
|
||||
void DataSource::PushEditNameId(int index) { m_name->PushEditNameId(index); }
|
||||
void DataSource::PushEditNameId(int index) {
|
||||
m_name->PushEditNameId(index);
|
||||
}
|
||||
|
||||
void DataSource::PushEditNameId(const char* name) {
|
||||
m_name->PushEditNameId(name);
|
||||
@@ -134,6 +148,8 @@ void DataSource::EmitDrag(ImGuiDragDropFlags flags) const {
|
||||
|
||||
DataSource* DataSource::Find(wpi::StringRef id) {
|
||||
auto it = gContext->sources.find(id);
|
||||
if (it == gContext->sources.end()) return nullptr;
|
||||
if (it == gContext->sources.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return it->getValue().source;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user