[PATCH 1 of 2] reachableroots: bail if integer object cannot be allocated
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sat Aug 15 05:41:09 UTC 2015
On 08/14/2015 03:25 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1439523116 -32400
> # Fri Aug 14 12:31:56 2015 +0900
> # Node ID 949f27368952a03365a84ec81d1a6aefe4e8319a
> # Parent 0b57b77f9b3ed5c1cc24ce95173c4f7e824df13f
> reachableroots: bail if integer object cannot be allocated
>
> This patch also replaces Py_XDECREF() by Py_DECREF() because we known "val"
> and "p" are not NULL.
>
> BTW, we can eliminate some of these allocation and error handling of int objects
> if the internal "seen" array has more information. For example,
>
> enum { SEEN = 1, ROOT = 2, REACHABLE = 4 };
> /* ... build ROOT mask from roots argument ... */
> if (seen[revnum + 1] & ROOT) { /* instead of PySet_Contains(roots, val) */
>
> From my quick hack, it is 2x faster.
Same logic probably apply for reachable. If we do not have to check the
python set for content we can probably be faster.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list