Minor performance tweak for deque.index() with a start argument (GH-9440)

This commit is contained in:
Raymond Hettinger 2018-09-21 01:46:41 -07:00 committed by GitHub
parent fb3e9c00ed
commit b46ad5431d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -1050,8 +1050,10 @@ deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
start = stop;
assert(0 <= start && start <= stop && stop <= Py_SIZE(deque));
/* XXX Replace this loop with faster code from deque_item() */
for (i=0 ; i<start ; i++) {
for (i=0 ; i < start - BLOCKLEN ; i += BLOCKLEN) {
b = b->rightlink;
}
for ( ; i < start ; i++) {
index++;
if (index == BLOCKLEN) {
b = b->rightlink;