diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 21:11:11 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 21:11:11 (GMT) |
commit | 35fc7606f076f507bd25acaf464e83c75c3756f4 (patch) | |
tree | 30ac7b6223407e2660a1c7d542f01a1560b407d0 /Objects/tupleobject.c | |
parent | 606edc1d971a0c5e4f5d379ecfa69f42b5b1d691 (diff) | |
download | cpython-35fc7606f076f507bd25acaf464e83c75c3756f4.zip cpython-35fc7606f076f507bd25acaf464e83c75c3756f4.tar.gz cpython-35fc7606f076f507bd25acaf464e83c75c3756f4.tar.bz2 |
SF #561244 Micro optimizations
Convert loops to memset()s.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index a207102..525e8f6 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -26,7 +26,6 @@ int tuple_zero_allocs; PyObject * PyTuple_New(register int size) { - register int i; register PyTupleObject *op; if (size < 0) { PyErr_BadInternalCall(); @@ -71,8 +70,7 @@ PyTuple_New(register int size) if (op == NULL) return NULL; } - for (i = 0; i < size; i++) - op->ob_item[i] = NULL; + memset(op->ob_item, 0, sizeof(*op->ob_item) * size); #if MAXSAVESIZE > 0 if (size == 0) { free_tuples[0] = op; @@ -697,8 +695,9 @@ _PyTuple_Resize(PyObject **pv, int newsize) } _Py_NewReference((PyObject *) sv); /* Zero out items added by growing */ - for (i = oldsize; i < newsize; i++) - sv->ob_item[i] = NULL; + if (newsize > oldsize) + memset(sv->ob_item, 0, + sizeof(*sv->ob_item) * (newsize - oldsize)); *pv = (PyObject *) sv; _PyObject_GC_TRACK(sv); return 0; |