Mercurial > hg
changeset 26041:8da628be211b
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Aug 2015 18:03:47 +0900 |
parents | 84dcc37b1272 |
children | 2a3010ba6f52 |
files | mercurial/parsers.c |
diffstat | 1 files changed, 26 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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); } } }