mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
Special case endpoint access for speed.
This commit is contained in:
parent
30e97dbe96
commit
6c79a518e7
1 changed files with 18 additions and 10 deletions
|
|
@ -326,6 +326,13 @@ deque_item(dequeobject *deque, int i)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
i = deque->leftindex;
|
||||||
|
b = deque->leftblock;
|
||||||
|
} else if (i == deque->len - 1) {
|
||||||
|
i = deque->rightindex;
|
||||||
|
b = deque->rightblock;
|
||||||
|
} else {
|
||||||
i += deque->leftindex;
|
i += deque->leftindex;
|
||||||
n = i / BLOCKLEN;
|
n = i / BLOCKLEN;
|
||||||
i %= BLOCKLEN;
|
i %= BLOCKLEN;
|
||||||
|
|
@ -339,6 +346,7 @@ deque_item(dequeobject *deque, int i)
|
||||||
while (n--)
|
while (n--)
|
||||||
b = b->leftlink;
|
b = b->leftlink;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
item = b->data[i];
|
item = b->data[i];
|
||||||
Py_INCREF(item);
|
Py_INCREF(item);
|
||||||
return item;
|
return item;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue