# HG changeset patch # User Yuya Nishihara # Date 1595065126 -32400 # Node ID a6fde9d789d91299052d4b3fe5b0d6a697323732 # Parent ba5e4b11d085301a06d55aec02633a660ba1754b phases: move short-lived PyObject pointers to local scope It helps understand which object should be decrefed on goto release. diff -r ba5e4b11d085 -r a6fde9d789d9 mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Sat Jul 18 18:35:17 2020 +0900 +++ b/mercurial/cext/revlog.c Sat Jul 18 18:38:46 2020 +0900 @@ -791,10 +791,7 @@ 96: internal */ static const char trackedphases[] = {1, 2, 32, 96}; PyObject *roots = Py_None; - PyObject *pyphase = NULL; - PyObject *pyrev = NULL; PyObject *phasesetsdict = NULL; - PyObject *phaseroots = NULL; PyObject *phasesets[4] = {NULL, NULL, NULL, NULL}; Py_ssize_t len = index_length(self); char *phases = NULL; @@ -815,7 +812,8 @@ } for (i = 0; i < numphases; ++i) { - pyphase = PyInt_FromLong(trackedphases[i]); + PyObject *pyphase = PyInt_FromLong(trackedphases[i]); + PyObject *phaseroots = NULL; if (pyphase == NULL) goto release; phaseroots = PyDict_GetItem(roots, pyphase); @@ -824,7 +822,6 @@ continue; rev = add_roots_get_min(self, phaseroots, phases, trackedphases[i]); - phaseroots = NULL; if (rev == -2) goto release; if (rev != -1 && (minphaserev == -1 || rev < minphaserev)) @@ -840,6 +837,8 @@ if (minphaserev == -1) minphaserev = len; for (rev = minphaserev; rev < len; ++rev) { + PyObject *pyphase = NULL; + PyObject *pyrev = NULL; int parents[2]; /* * The parent lookup could be skipped for phaseroots, but @@ -886,7 +885,7 @@ if (phasesetsdict == NULL) goto release; for (i = 0; i < numphases; ++i) { - pyphase = PyInt_FromLong(trackedphases[i]); + PyObject *pyphase = PyInt_FromLong(trackedphases[i]); if (pyphase == NULL) goto release; if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) ==