summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-06-13 21:11:11 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-06-13 21:11:11 (GMT)
commit35fc7606f076f507bd25acaf464e83c75c3756f4 (patch)
tree30ac7b6223407e2660a1c7d542f01a1560b407d0 /Objects/listobject.c
parent606edc1d971a0c5e4f5d379ecfa69f42b5b1d691 (diff)
downloadcpython-35fc7606f076f507bd25acaf464e83c75c3756f4.zip
cpython-35fc7606f076f507bd25acaf464e83c75c3756f4.tar.gz
cpython-35fc7606f076f507bd25acaf464e83c75c3756f4.tar.bz2
SF #561244 Micro optimizations
Convert loops to memset()s.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index f29774e..78cc679 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -56,7 +56,6 @@ do { \
PyObject *
PyList_New(int size)
{
- int i;
PyListObject *op;
size_t nbytes;
if (size < 0) {
@@ -80,10 +79,9 @@ PyList_New(int size)
if (op->ob_item == NULL) {
return PyErr_NoMemory();
}
+ memset(op->ob_item, 0, sizeof(*op->ob_item) * size);
}
op->ob_size = size;
- for (i = 0; i < size; i++)
- op->ob_item[i] = NULL;
_PyObject_GC_TRACK(op);
return (PyObject *) op;
}
@@ -1576,8 +1574,7 @@ list_fill(PyListObject *result, PyObject *v)
PyErr_NoMemory();
goto error;
}
- for (i = 0; i < n; i++)
- result->ob_item[i] = NULL;
+ memset(result->ob_item, 0, sizeof(*result->ob_item) * n);
result->ob_size = n;
/* Run iterator to exhaustion. */