[PATCH 2 of 2] reachableroots: unroll loop that checks if one of parents is reachable
Yuya Nishihara
yuya at tcha.org
Tue Sep 8 20:26:05 CDT 2015
On Tue, 08 Sep 2015 13:45:19 -0700, Pierre-Yves David wrote:
> > The difference is small, but fewer loops should be better in general:
> >
> > revset #0: 0::tip
> > 0) 0.001609
> > 1) 0.001510 93%
>
> I'm kinda surprise the compiler is not doing this for us.
Perhaps it isn't easy to detect that
revstates[i + 1] is RS_REACHABLE at k == 1
if revstates[parents[k] + 1] is RS_REACHABLE at k == 0.
gcc 5.2.1 could generate optimized code if we had "break".
> for (k = 0; k < 2; k++) {
> - if ((revstates[parents[k] + 1] & RS_REACHABLE)
> - && !(revstates[i + 1] & RS_REACHABLE)) {
> - revstates[i + 1] |= RS_REACHABLE;
> - val = PyInt_FromLong(i);
> - if (val == NULL)
> - goto bail;
> - r = PyList_Append(reachable, val);
> - Py_DECREF(val);
> - if (r < 0)
> - goto bail;
break; /* revision i is reachable */
> - }
More information about the Mercurial-devel
mailing list