SF #561244 Micro optimizations

Convert loops to memset()s.
This commit is contained in:
Neal Norwitz 2002-06-13 21:11:11 +00:00
parent 606edc1d97
commit 35fc7606f0
3 changed files with 7 additions and 14 deletions

View File

@ -1376,13 +1376,10 @@ sre_getlower(PyObject* self, PyObject* args)
LOCAL(void)
state_reset(SRE_STATE* state)
{
int i;
state->lastmark = 0;
/* FIXME: dynamic! */
for (i = 0; i < SRE_MARK_SIZE; i++)
state->mark[i] = NULL;
memset(state->mark, 0, sizeof(*state->mark) * SRE_MARK_SIZE);
state->lastindex = -1;

View File

@ -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. */

View File

@ -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;