phases: rename variable used for owned dict of phasesets
authorYuya Nishihara <yuya@tcha.org>
Sat, 18 Jul 2020 18:35:17 +0900
changeset 45179 ba5e4b11d085
parent 45178 b00fa1782efe
child 45180 a6fde9d789d9
phases: rename variable used for owned dict of phasesets The phaseroots variable is used for two different objects: borrowed set and owned dict of sets. It's hard to track which object should have to be decrefed on error return.
mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c	Sat Jul 18 18:27:39 2020 +0900
+++ b/mercurial/cext/revlog.c	Sat Jul 18 18:35:17 2020 +0900
@@ -793,6 +793,7 @@
 	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);
@@ -880,14 +881,16 @@
 		}
 		Py_DECREF(pyrev);
 	}
-	phaseroots = _dict_new_presized(numphases);
-	if (phaseroots == NULL)
+
+	phasesetsdict = _dict_new_presized(numphases);
+	if (phasesetsdict == NULL)
 		goto release;
 	for (i = 0; i < numphases; ++i) {
 		pyphase = PyInt_FromLong(trackedphases[i]);
 		if (pyphase == NULL)
 			goto release;
-		if (PyDict_SetItem(phaseroots, pyphase, phasesets[i]) == -1) {
+		if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) ==
+		    -1) {
 			Py_DECREF(pyphase);
 			goto release;
 		}
@@ -895,12 +898,12 @@
 		phasesets[i] = NULL;
 	}
 
-	return Py_BuildValue("nN", len, phaseroots);
+	return Py_BuildValue("nN", len, phasesetsdict);
 
 release:
 	for (i = 0; i < numphases; ++i)
 		Py_XDECREF(phasesets[i]);
-	Py_XDECREF(phaseroots);
+	Py_XDECREF(phasesetsdict);
 
 	free(phases);
 	return NULL;