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

@@ -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;
}