未验证 提交 bfa349b6 编写于 作者: P peno2 提交者: GitHub

Remove 2 redundant else, according to rule F.56 (#1766)

* Remove 2 redundant else, according to rule F.56

* Remove continue from example code

Update after pull request comment.
上级 211f6cfe
......@@ -12595,10 +12595,8 @@ Readability. Error prevention. Efficiency.
cout << f(v, &v[i]) << '\n';
for (gsl::index i = 0; i < v.size(); ++i) { // body messes with loop variable: can't be a range-for
if (i % 2 == 0)
continue; // skip even elements
else
cout << v[i] << '\n';
if (i % 2 != 0)
cout << v[i] << '\n'; // output odd elements
}
A human or a good static analyzer might determine that there really isn't a side effect on `v` in `f(v, &v[i])` so that the loop can be rewritten.
......@@ -20386,7 +20384,7 @@ In particular, the single-return rule makes it harder to concentrate error check
{
if (x < 0)
return "negative";
else if (x > 0)
if (x > 0)
return "positive";
return "zero";
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册