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

@@ -65,28 +65,36 @@ std::shared_ptr<Process> Process::SpawnArray(Loop& loop, const Twine& file,
break;
case Option::kStdioIgnore: {
size_t index = o.m_data.stdio.index;
if (index >= stdioBuf.size()) stdioBuf.resize(index + 1);
if (index >= stdioBuf.size()) {
stdioBuf.resize(index + 1);
}
stdioBuf[index].flags = UV_IGNORE;
stdioBuf[index].data.fd = 0;
break;
}
case Option::kStdioInheritFd: {
size_t index = o.m_data.stdio.index;
if (index >= stdioBuf.size()) stdioBuf.resize(index + 1);
if (index >= stdioBuf.size()) {
stdioBuf.resize(index + 1);
}
stdioBuf[index].flags = UV_INHERIT_FD;
stdioBuf[index].data.fd = o.m_data.stdio.fd;
break;
}
case Option::kStdioInheritPipe: {
size_t index = o.m_data.stdio.index;
if (index >= stdioBuf.size()) stdioBuf.resize(index + 1);
if (index >= stdioBuf.size()) {
stdioBuf.resize(index + 1);
}
stdioBuf[index].flags = UV_INHERIT_STREAM;
stdioBuf[index].data.stream = o.m_data.stdio.pipe->GetRawStream();
break;
}
case Option::kStdioCreatePipe: {
size_t index = o.m_data.stdio.index;
if (index >= stdioBuf.size()) stdioBuf.resize(index + 1);
if (index >= stdioBuf.size()) {
stdioBuf.resize(index + 1);
}
stdioBuf[index].flags =
static_cast<uv_stdio_flags>(UV_CREATE_PIPE | o.m_data.stdio.flags);
stdioBuf[index].data.stream = o.m_data.stdio.pipe->GetRawStream();
@@ -97,7 +105,9 @@ std::shared_ptr<Process> Process::SpawnArray(Loop& loop, const Twine& file,
}
}
if (argsBuf.empty()) argsBuf.push_back(const_cast<char*>(coptions.file));
if (argsBuf.empty()) {
argsBuf.push_back(const_cast<char*>(coptions.file));
}
argsBuf.push_back(nullptr);
coptions.args = argsBuf.data();