Commit 6c79a518 authored by Raymond Hettinger's avatar Raymond Hettinger

Special case endpoint access for speed.

parent 30e97dbe
......@@ -326,6 +326,13 @@ deque_item(dequeobject *deque, int i)
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;
n = i / BLOCKLEN;
i %= BLOCKLEN;
......@@ -339,6 +346,7 @@ deque_item(dequeobject *deque, int i)
while (n--)
b = b->leftlink;
}
}
item = b->data[i];
Py_INCREF(item);
return item;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment