Show More
@@ -1230,25 +1230,31 b' static PyObject *index_getitem(indexObje' | |||||
1230 | return NULL; |
|
1230 | return NULL; | |
1231 | } |
|
1231 | } | |
1232 |
|
1232 | |||
|
1233 | /* | |||
|
1234 | * Fully populate the radix tree. | |||
|
1235 | */ | |||
|
1236 | static int nt_populate(indexObject *self) { | |||
|
1237 | int rev; | |||
|
1238 | if (self->ntrev > 0) { | |||
|
1239 | for (rev = self->ntrev - 1; rev >= 0; rev--) { | |||
|
1240 | const char *n = index_node_existing(self, rev); | |||
|
1241 | if (n == NULL) | |||
|
1242 | return -1; | |||
|
1243 | if (nt_insert(self, n, rev) == -1) | |||
|
1244 | return -1; | |||
|
1245 | } | |||
|
1246 | self->ntrev = rev; | |||
|
1247 | } | |||
|
1248 | return 0; | |||
|
1249 | } | |||
|
1250 | ||||
1233 | static int nt_partialmatch(indexObject *self, const char *node, |
|
1251 | static int nt_partialmatch(indexObject *self, const char *node, | |
1234 | Py_ssize_t nodelen) |
|
1252 | Py_ssize_t nodelen) | |
1235 | { |
|
1253 | { | |
1236 | int rev; |
|
|||
1237 |
|
||||
1238 | if (nt_init(self) == -1) |
|
1254 | if (nt_init(self) == -1) | |
1239 | return -3; |
|
1255 | return -3; | |
1240 |
|
1256 | if (nt_populate(self) == -1) | ||
1241 | if (self->ntrev > 0) { |
|
1257 | return -3; | |
1242 | /* ensure that the radix tree is fully populated */ |
|
|||
1243 | for (rev = self->ntrev - 1; rev >= 0; rev--) { |
|
|||
1244 | const char *n = index_node_existing(self, rev); |
|
|||
1245 | if (n == NULL) |
|
|||
1246 | return -3; |
|
|||
1247 | if (nt_insert(self, n, rev) == -1) |
|
|||
1248 | return -3; |
|
|||
1249 | } |
|
|||
1250 | self->ntrev = rev; |
|
|||
1251 | } |
|
|||
1252 |
|
1258 | |||
1253 | return nt_find(self, node, nodelen, 1); |
|
1259 | return nt_find(self, node, nodelen, 1); | |
1254 | } |
|
1260 | } |
General Comments 0
You need to be logged in to leave comments.
Login now