reachableroots: reduce nesting level by jumping to next iteration by continue
This can eliminate lines over 80 columns. No code change except for the
outermost "if" condition.
--- a/mercurial/parsers.c Mon Aug 17 22:56:12 2015 -0400
+++ b/mercurial/parsers.c Sat Aug 15 18:03:47 2015 +0900
@@ -1197,16 +1197,16 @@
Py_DECREF(val);
/* Add its parents to the list of nodes to visit */
- if (revnum != -1) {
- r = index_get_parents(self, revnum, parents, (int)len - 1);
- if (r < 0)
- goto bail;
-
- for (i = 0; i < 2; i++) {
- if (seen[parents[i] + 1] == 0 && parents[i] >= minroot) {
- tovisit[lentovisit++] = parents[i];
- seen[parents[i] + 1] = 1;
- }
+ if (revnum == -1)
+ continue;
+ r = index_get_parents(self, revnum, parents, (int)len - 1);
+ if (r < 0)
+ goto bail;
+ for (i = 0; i < 2; i++) {
+ if (seen[parents[i] + 1] == 0
+ && parents[i] >= minroot) {
+ tovisit[lentovisit++] = parents[i];
+ seen[parents[i] + 1] = 1;
}
}
}
@@ -1218,24 +1218,25 @@
if (minidx < 0)
minidx = 0;
for (i = minidx; i < len; i++) {
- if (seen[i + 1] == 1) {
- r = index_get_parents(self, i, parents, (int)len - 1);
- /* Corrupted index file, error is set from index_get_parents */
- if (r < 0)
+ if (seen[i + 1] != 1)
+ continue;
+ r = index_get_parents(self, i, parents, (int)len - 1);
+ /* Corrupted index file, error is set from
+ * index_get_parents */
+ if (r < 0)
+ goto bail;
+ for (k = 0; k < 2; k++) {
+ PyObject *p = PyInt_FromLong(parents[k]);
+ if (p == NULL)
goto bail;
- for (k = 0; k < 2; k++) {
- PyObject *p = PyInt_FromLong(parents[k]);
- if (p == NULL)
+ if (PySet_Contains(reachable, p) == 1) {
+ val = PyInt_FromLong(i);
+ if (val == NULL)
goto bail;
- if (PySet_Contains(reachable, p) == 1) {
- val = PyInt_FromLong(i);
- if (val == NULL)
- goto bail;
- PySet_Add(reachable, val);
- Py_DECREF(val);
- }
- Py_DECREF(p);
+ PySet_Add(reachable, val);
+ Py_DECREF(val);
}
+ Py_DECREF(p);
}
}
}