Mercurial > hg
comparison mercurial/cext/revlog.c @ 45179:ba5e4b11d085
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 18 Jul 2020 18:35:17 +0900 |
parents | b00fa1782efe |
children | a6fde9d789d9 |
comparison
equal
deleted
inserted
replaced
45178:b00fa1782efe | 45179:ba5e4b11d085 |
---|---|
791 96: internal */ | 791 96: internal */ |
792 static const char trackedphases[] = {1, 2, 32, 96}; | 792 static const char trackedphases[] = {1, 2, 32, 96}; |
793 PyObject *roots = Py_None; | 793 PyObject *roots = Py_None; |
794 PyObject *pyphase = NULL; | 794 PyObject *pyphase = NULL; |
795 PyObject *pyrev = NULL; | 795 PyObject *pyrev = NULL; |
796 PyObject *phasesetsdict = NULL; | |
796 PyObject *phaseroots = NULL; | 797 PyObject *phaseroots = NULL; |
797 PyObject *phasesets[4] = {NULL, NULL, NULL, NULL}; | 798 PyObject *phasesets[4] = {NULL, NULL, NULL, NULL}; |
798 Py_ssize_t len = index_length(self); | 799 Py_ssize_t len = index_length(self); |
799 char *phases = NULL; | 800 char *phases = NULL; |
800 int minphaserev = -1, rev, i; | 801 int minphaserev = -1, rev, i; |
878 Py_DECREF(pyrev); | 879 Py_DECREF(pyrev); |
879 goto release; | 880 goto release; |
880 } | 881 } |
881 Py_DECREF(pyrev); | 882 Py_DECREF(pyrev); |
882 } | 883 } |
883 phaseroots = _dict_new_presized(numphases); | 884 |
884 if (phaseroots == NULL) | 885 phasesetsdict = _dict_new_presized(numphases); |
886 if (phasesetsdict == NULL) | |
885 goto release; | 887 goto release; |
886 for (i = 0; i < numphases; ++i) { | 888 for (i = 0; i < numphases; ++i) { |
887 pyphase = PyInt_FromLong(trackedphases[i]); | 889 pyphase = PyInt_FromLong(trackedphases[i]); |
888 if (pyphase == NULL) | 890 if (pyphase == NULL) |
889 goto release; | 891 goto release; |
890 if (PyDict_SetItem(phaseroots, pyphase, phasesets[i]) == -1) { | 892 if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) == |
893 -1) { | |
891 Py_DECREF(pyphase); | 894 Py_DECREF(pyphase); |
892 goto release; | 895 goto release; |
893 } | 896 } |
894 Py_DECREF(phasesets[i]); | 897 Py_DECREF(phasesets[i]); |
895 phasesets[i] = NULL; | 898 phasesets[i] = NULL; |
896 } | 899 } |
897 | 900 |
898 return Py_BuildValue("nN", len, phaseroots); | 901 return Py_BuildValue("nN", len, phasesetsdict); |
899 | 902 |
900 release: | 903 release: |
901 for (i = 0; i < numphases; ++i) | 904 for (i = 0; i < numphases; ++i) |
902 Py_XDECREF(phasesets[i]); | 905 Py_XDECREF(phasesets[i]); |
903 Py_XDECREF(phaseroots); | 906 Py_XDECREF(phasesetsdict); |
904 | 907 |
905 free(phases); | 908 free(phases); |
906 return NULL; | 909 return NULL; |
907 } | 910 } |
908 | 911 |