Show More
@@ -84,8 +84,8 b' struct indexObjectStruct {' | |||
|
84 | 84 | static Py_ssize_t index_length(const indexObject *self) |
|
85 | 85 | { |
|
86 | 86 | if (self->added == NULL) |
|
87 |
return self->length |
|
|
88 |
return self->length + PyList_GET_SIZE(self->added) |
|
|
87 | return self->length; | |
|
88 | return self->length + PyList_GET_SIZE(self->added); | |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | static PyObject *nullentry; |
@@ -124,9 +124,8 b' static const char *index_deref(indexObje' | |||
|
124 | 124 | static inline int index_get_parents(indexObject *self, Py_ssize_t rev, |
|
125 | 125 | int *ps, int maxrev) |
|
126 | 126 | { |
|
127 |
if (rev >= self->length |
|
|
128 | PyObject *tuple = PyList_GET_ITEM(self->added, | |
|
129 | rev - self->length + 1); | |
|
127 | if (rev >= self->length) { | |
|
128 | PyObject *tuple = PyList_GET_ITEM(self->added, rev - self->length); | |
|
130 | 129 | ps[0] = (int)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 5)); |
|
131 | 130 | ps[1] = (int)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 6)); |
|
132 | 131 | } else { |
@@ -175,9 +174,9 b' static PyObject *index_get(indexObject *' | |||
|
175 | 174 | return NULL; |
|
176 | 175 | } |
|
177 | 176 | |
|
178 |
if (pos >= self->length |
|
|
177 | if (pos >= self->length) { | |
|
179 | 178 | PyObject *obj; |
|
180 |
obj = PyList_GET_ITEM(self->added, pos - self->length |
|
|
179 | obj = PyList_GET_ITEM(self->added, pos - self->length); | |
|
181 | 180 | Py_INCREF(obj); |
|
182 | 181 | return obj; |
|
183 | 182 | } |
@@ -241,9 +240,9 b' static const char *index_node(indexObjec' | |||
|
241 | 240 | if (pos >= length) |
|
242 | 241 | return NULL; |
|
243 | 242 | |
|
244 |
if (pos >= self->length |
|
|
243 | if (pos >= self->length) { | |
|
245 | 244 | PyObject *tuple, *str; |
|
246 |
tuple = PyList_GET_ITEM(self->added, pos - self->length |
|
|
245 | tuple = PyList_GET_ITEM(self->added, pos - self->length); | |
|
247 | 246 | str = PyTuple_GetItem(tuple, 7); |
|
248 | 247 | return str ? PyBytes_AS_STRING(str) : NULL; |
|
249 | 248 | } |
@@ -338,7 +337,7 b' static PyObject *index_stats(indexObject' | |||
|
338 | 337 | Py_DECREF(t); |
|
339 | 338 | } |
|
340 | 339 | |
|
341 |
if (self->raw_length != self->length |
|
|
340 | if (self->raw_length != self->length) | |
|
342 | 341 | istat(raw_length, "revs on disk"); |
|
343 | 342 | istat(length, "revs in memory"); |
|
344 | 343 | istat(ntlookups, "node trie lookups"); |
@@ -802,9 +801,8 b' static inline int index_baserev(indexObj' | |||
|
802 | 801 | { |
|
803 | 802 | const char *data; |
|
804 | 803 | |
|
805 |
if (rev >= self->length |
|
|
806 | PyObject *tuple = PyList_GET_ITEM(self->added, | |
|
807 | rev - self->length + 1); | |
|
804 | if (rev >= self->length) { | |
|
805 | PyObject *tuple = PyList_GET_ITEM(self->added, rev - self->length); | |
|
808 | 806 | return (int)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 3)); |
|
809 | 807 | } |
|
810 | 808 | else { |
@@ -1827,11 +1825,11 b' static int index_slice_del(indexObject *' | |||
|
1827 | 1825 | return -1; |
|
1828 | 1826 | } |
|
1829 | 1827 | |
|
1830 |
if (start < self->length |
|
|
1828 | if (start < self->length) { | |
|
1831 | 1829 | if (self->nt) { |
|
1832 | 1830 | Py_ssize_t i; |
|
1833 | 1831 | |
|
1834 |
for (i = start + 1; i < self->length |
|
|
1832 | for (i = start + 1; i < self->length; i++) { | |
|
1835 | 1833 | const char *node = index_node_existing(self, i); |
|
1836 | 1834 | if (node == NULL) |
|
1837 | 1835 | return -1; |
@@ -1843,7 +1841,7 b' static int index_slice_del(indexObject *' | |||
|
1843 | 1841 | if (self->ntrev > start) |
|
1844 | 1842 | self->ntrev = (int)start; |
|
1845 | 1843 | } |
|
1846 |
self->length = start |
|
|
1844 | self->length = start; | |
|
1847 | 1845 | if (start < self->raw_length) { |
|
1848 | 1846 | if (self->cache) { |
|
1849 | 1847 | Py_ssize_t i; |
@@ -1856,12 +1854,12 b' static int index_slice_del(indexObject *' | |||
|
1856 | 1854 | } |
|
1857 | 1855 | |
|
1858 | 1856 | if (self->nt) { |
|
1859 |
index_invalidate_added(self, start - self->length |
|
|
1857 | index_invalidate_added(self, start - self->length); | |
|
1860 | 1858 | if (self->ntrev > start) |
|
1861 | 1859 | self->ntrev = (int)start; |
|
1862 | 1860 | } |
|
1863 | 1861 | if (self->added) |
|
1864 |
ret = PyList_SetSlice(self->added, start - self->length |
|
|
1862 | ret = PyList_SetSlice(self->added, start - self->length, | |
|
1865 | 1863 | PyList_GET_SIZE(self->added), NULL); |
|
1866 | 1864 | done: |
|
1867 | 1865 | Py_CLEAR(self->headrevs); |
@@ -1974,14 +1972,14 b' static int index_init(indexObject *self,' | |||
|
1974 | 1972 | if (len == -1) |
|
1975 | 1973 | goto bail; |
|
1976 | 1974 | self->raw_length = len; |
|
1977 |
self->length = len |
|
|
1975 | self->length = len; | |
|
1978 | 1976 | } else { |
|
1979 | 1977 | if (size % v1_hdrsize) { |
|
1980 | 1978 | PyErr_SetString(PyExc_ValueError, "corrupt index file"); |
|
1981 | 1979 | goto bail; |
|
1982 | 1980 | } |
|
1983 | 1981 | self->raw_length = size / v1_hdrsize; |
|
1984 |
self->length = self->raw_length |
|
|
1982 | self->length = self->raw_length; | |
|
1985 | 1983 | } |
|
1986 | 1984 | |
|
1987 | 1985 | return 0; |
General Comments 0
You need to be logged in to leave comments.
Login now