equal
deleted
inserted
replaced
1249 } |
1249 } |
1250 |
1250 |
1251 /* |
1251 /* |
1252 * Fully populate the radix tree. |
1252 * Fully populate the radix tree. |
1253 */ |
1253 */ |
1254 static int nt_populate(indexObject *self) { |
1254 static int index_populate_nt(indexObject *self) { |
1255 int rev; |
1255 int rev; |
1256 if (self->ntrev > 0) { |
1256 if (self->ntrev > 0) { |
1257 for (rev = self->ntrev - 1; rev >= 0; rev--) { |
1257 for (rev = self->ntrev - 1; rev >= 0; rev--) { |
1258 const char *n = index_node_existing(self, rev); |
1258 const char *n = index_node_existing(self, rev); |
1259 if (n == NULL) |
1259 if (n == NULL) |
1346 Py_RETURN_NONE; |
1346 Py_RETURN_NONE; |
1347 } |
1347 } |
1348 |
1348 |
1349 if (index_init_nt(self) == -1) |
1349 if (index_init_nt(self) == -1) |
1350 return NULL; |
1350 return NULL; |
1351 if (nt_populate(self) == -1) |
1351 if (index_populate_nt(self) == -1) |
1352 return NULL; |
1352 return NULL; |
1353 rev = nt_partialmatch(self->nt, node, nodelen); |
1353 rev = nt_partialmatch(self->nt, node, nodelen); |
1354 |
1354 |
1355 switch (rev) { |
1355 switch (rev) { |
1356 case -4: |
1356 case -4: |
1381 return NULL; |
1381 return NULL; |
1382 |
1382 |
1383 self->ntlookups++; |
1383 self->ntlookups++; |
1384 if (index_init_nt(self) == -1) |
1384 if (index_init_nt(self) == -1) |
1385 return NULL; |
1385 return NULL; |
1386 if (nt_populate(self) == -1) |
1386 if (index_populate_nt(self) == -1) |
1387 return NULL; |
1387 return NULL; |
1388 length = nt_shortest(self->nt, node); |
1388 length = nt_shortest(self->nt, node); |
1389 if (length == -3) |
1389 if (length == -3) |
1390 return NULL; |
1390 return NULL; |
1391 if (length == -2) { |
1391 if (length == -2) { |
1797 } |
1797 } |
1798 |
1798 |
1799 /* |
1799 /* |
1800 * Invalidate any trie entries introduced by added revs. |
1800 * Invalidate any trie entries introduced by added revs. |
1801 */ |
1801 */ |
1802 static void nt_invalidate_added(indexObject *self, Py_ssize_t start) |
1802 static void index_invalidate_added(indexObject *self, Py_ssize_t start) |
1803 { |
1803 { |
1804 Py_ssize_t i, len = PyList_GET_SIZE(self->added); |
1804 Py_ssize_t i, len = PyList_GET_SIZE(self->added); |
1805 |
1805 |
1806 for (i = start; i < len; i++) { |
1806 for (i = start; i < len; i++) { |
1807 PyObject *tuple = PyList_GET_ITEM(self->added, i); |
1807 PyObject *tuple = PyList_GET_ITEM(self->added, i); |
1867 return -1; |
1867 return -1; |
1868 |
1868 |
1869 nt_delete_node(self->nt, node); |
1869 nt_delete_node(self->nt, node); |
1870 } |
1870 } |
1871 if (self->added) |
1871 if (self->added) |
1872 nt_invalidate_added(self, 0); |
1872 index_invalidate_added(self, 0); |
1873 if (self->ntrev > start) |
1873 if (self->ntrev > start) |
1874 self->ntrev = (int)start; |
1874 self->ntrev = (int)start; |
1875 } |
1875 } |
1876 self->length = start + 1; |
1876 self->length = start + 1; |
1877 if (start < self->raw_length) { |
1877 if (start < self->raw_length) { |
1884 } |
1884 } |
1885 goto done; |
1885 goto done; |
1886 } |
1886 } |
1887 |
1887 |
1888 if (self->nt) { |
1888 if (self->nt) { |
1889 nt_invalidate_added(self, start - self->length + 1); |
1889 index_invalidate_added(self, start - self->length + 1); |
1890 if (self->ntrev > start) |
1890 if (self->ntrev > start) |
1891 self->ntrev = (int)start; |
1891 self->ntrev = (int)start; |
1892 } |
1892 } |
1893 if (self->added) |
1893 if (self->added) |
1894 ret = PyList_SetSlice(self->added, start - self->length + 1, |
1894 ret = PyList_SetSlice(self->added, start - self->length + 1, |