mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +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,18 +326,26 @@ deque_item(dequeobject *deque, int i)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += deque->leftindex;
|
if (i == 0) {
|
||||||
n = i / BLOCKLEN;
|
i = deque->leftindex;
|
||||||
i %= BLOCKLEN;
|
|
||||||
if (i < (deque->len >> 1)) {
|
|
||||||
b = deque->leftblock;
|
b = deque->leftblock;
|
||||||
while (n--)
|
} else if (i == deque->len - 1) {
|
||||||
b = b->rightlink;
|
i = deque->rightindex;
|
||||||
} else {
|
|
||||||
n = (deque->leftindex + deque->len - 1) / BLOCKLEN - n;
|
|
||||||
b = deque->rightblock;
|
b = deque->rightblock;
|
||||||
while (n--)
|
} else {
|
||||||
b = b->leftlink;
|
i += deque->leftindex;
|
||||||
|
n = i / BLOCKLEN;
|
||||||
|
i %= BLOCKLEN;
|
||||||
|
if (i < (deque->len >> 1)) {
|
||||||
|
b = deque->leftblock;
|
||||||
|
while (n--)
|
||||||
|
b = b->rightlink;
|
||||||
|
} else {
|
||||||
|
n = (deque->leftindex + deque->len - 1) / BLOCKLEN - n;
|
||||||
|
b = deque->rightblock;
|
||||||
|
while (n--)
|
||||||
|
b = b->leftlink;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
item = b->data[i];
|
item = b->data[i];
|
||||||
Py_INCREF(item);
|
Py_INCREF(item);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue