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

@@ -38,18 +38,22 @@ void Stream::Shutdown(const std::shared_ptr<ShutdownReq>& req) {
if (Invoke(&uv_shutdown, req->GetRaw(), GetRawStream(),
[](uv_shutdown_t* req, int status) {
auto& h = *static_cast<ShutdownReq*>(req->data);
if (status < 0)
if (status < 0) {
h.ReportError(status);
else
} else {
h.complete();
}
h.Release(); // this is always a one-shot
}))
})) {
req->Keep();
}
}
void Stream::Shutdown(std::function<void()> callback) {
auto req = std::make_shared<ShutdownReq>();
if (callback) req->complete.connect(callback);
if (callback) {
req->complete.connect(callback);
}
Shutdown(req);
}
@@ -60,12 +64,13 @@ void Stream::StartRead() {
Buffer data = *buf;
// nread=0 is simply ignored
if (nread == UV_EOF)
if (nread == UV_EOF) {
h.end();
else if (nread > 0)
} else if (nread > 0) {
h.data(data, static_cast<size_t>(nread));
else if (nread < 0)
} else if (nread < 0) {
h.ReportError(nread);
}
// free the buffer
h.FreeBuf(data);
@@ -77,11 +82,14 @@ void Stream::Write(ArrayRef<Buffer> bufs,
if (Invoke(&uv_write, req->GetRaw(), GetRawStream(), bufs.data(), bufs.size(),
[](uv_write_t* r, int status) {
auto& h = *static_cast<WriteReq*>(r->data);
if (status < 0) h.ReportError(status);
if (status < 0) {
h.ReportError(status);
}
h.finish(Error(status));
h.Release(); // this is always a one-shot
}))
})) {
req->Keep();
}
}
void Stream::Write(