816 } |
816 } |
817 |
817 |
818 static PyObject *index_stats(indexObject *self) |
818 static PyObject *index_stats(indexObject *self) |
819 { |
819 { |
820 PyObject *obj = PyDict_New(); |
820 PyObject *obj = PyDict_New(); |
|
821 PyObject *t = NULL; |
821 |
822 |
822 if (obj == NULL) |
823 if (obj == NULL) |
823 return NULL; |
824 return NULL; |
824 |
825 |
825 #define istat(__n, __d) \ |
826 #define istat(__n, __d) \ |
826 if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \ |
827 t = PyInt_FromSsize_t(self->__n); \ |
827 goto bail; |
828 if (!t) \ |
|
829 goto bail; \ |
|
830 if (PyDict_SetItemString(obj, __d, t) == -1) \ |
|
831 goto bail; \ |
|
832 Py_DECREF(t); |
828 |
833 |
829 if (self->added) { |
834 if (self->added) { |
830 Py_ssize_t len = PyList_GET_SIZE(self->added); |
835 Py_ssize_t len = PyList_GET_SIZE(self->added); |
831 if (PyDict_SetItemString(obj, "index entries added", |
836 t = PyInt_FromSsize_t(len); |
832 PyInt_FromSsize_t(len)) == -1) |
837 if (!t) |
833 goto bail; |
838 goto bail; |
|
839 if (PyDict_SetItemString(obj, "index entries added", t) == -1) |
|
840 goto bail; |
|
841 Py_DECREF(t); |
834 } |
842 } |
835 |
843 |
836 if (self->raw_length != self->length - 1) |
844 if (self->raw_length != self->length - 1) |
837 istat(raw_length, "revs on disk"); |
845 istat(raw_length, "revs on disk"); |
838 istat(length, "revs in memory"); |
846 istat(length, "revs in memory"); |