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

@@ -23,13 +23,19 @@ std::shared_ptr<Pipe> Pipe::Create(Loop& loop, bool ipc) {
}
void Pipe::Reuse(std::function<void()> callback, bool ipc) {
if (IsClosing()) return;
if (!m_reuseData) m_reuseData = std::make_unique<ReuseData>();
if (IsClosing()) {
return;
}
if (!m_reuseData) {
m_reuseData = std::make_unique<ReuseData>();
}
m_reuseData->callback = callback;
m_reuseData->ipc = ipc;
uv_close(GetRawHandle(), [](uv_handle_t* handle) {
Pipe& h = *static_cast<Pipe*>(handle->data);
if (!h.m_reuseData) return;
if (!h.m_reuseData) {
return;
}
auto data = std::move(h.m_reuseData);
auto err =
uv_pipe_init(h.GetLoopRef().GetRaw(), h.GetRaw(), data->ipc ? 1 : 0);
@@ -43,7 +49,9 @@ void Pipe::Reuse(std::function<void()> callback, bool ipc) {
std::shared_ptr<Pipe> Pipe::Accept() {
auto client = Create(GetLoopRef(), GetRaw()->ipc);
if (!client) return nullptr;
if (!client) {
return nullptr;
}
if (!Accept(client)) {
client->Release();
return nullptr;
@@ -51,7 +59,9 @@ std::shared_ptr<Pipe> Pipe::Accept() {
return client;
}
Pipe* Pipe::DoAccept() { return Accept().get(); }
Pipe* Pipe::DoAccept() {
return Accept().get();
}
void Pipe::Bind(const Twine& name) {
SmallString<128> nameBuf;
@@ -66,10 +76,11 @@ void Pipe::Connect(const Twine& name,
name.toNullTerminatedStringRef(nameBuf).data(),
[](uv_connect_t* req, int status) {
auto& h = *static_cast<PipeConnectReq*>(req->data);
if (status < 0)
if (status < 0) {
h.ReportError(status);
else
} else {
h.connected();
}
h.Release(); // this is always a one-shot
});
req->Keep();