[Python-checkins] python/nondist/sandbox/collections dequemodule.c,
1.1, 1.2
rhettinger at projects.sourceforge.net
rhettinger at projects.sourceforge.net
Mon Jan 26 11:28:03 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/collections
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9728
Modified Files:
dequemodule.c
Log Message:
Inline the append operation for the constructor (20% speedup).
Index: dequemodule.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/collections/dequemodule.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dequemodule.c 26 Jan 2004 05:25:38 -0000 1.1
--- dequemodule.c 26 Jan 2004 16:28:01 -0000 1.2
***************
*** 325,329 ****
deque_init(dequeobject *deque, PyObject *args, PyObject *kwds)
{
! PyObject *iterable = NULL, *it, *item, *rv;
if (!PyArg_UnpackTuple(args, "deque", 0, 1, &iterable))
--- 325,329 ----
deque_init(dequeobject *deque, PyObject *args, PyObject *kwds)
{
! PyObject *iterable = NULL, *it, *item;
if (!PyArg_UnpackTuple(args, "deque", 0, 1, &iterable))
***************
*** 336,345 ****
while ((item = PyIter_Next(it)) != NULL) {
! assert (item != NULL);
! rv = deque_append(deque, item);
! Py_DECREF(item);
! if (rv == NULL)
! return -1;
! Py_DECREF(rv);
}
Py_DECREF(it);
--- 336,353 ----
while ((item = PyIter_Next(it)) != NULL) {
! deque->rightindex++;
! deque->len++;
! if (deque->rightindex == BLOCKLEN) {
! block *b = newblock(deque->rightblock, NULL);
! if (b == NULL) {
! Py_DECREF(it);
! Py_DECREF(item);
! return -1;
! }
! deque->rightblock->rightlink = b;
! deque->rightblock = b;
! deque->rightindex = 0;
! }
! deque->rightblock->data[deque->rightindex] = item;
}
Py_DECREF(it);
More information about the Python-checkins
mailing list