summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-03-15 09:01:31 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-03-15 09:01:31 (GMT)
commitd4ff741e785b598df9737da10831f927fa0eddbb (patch)
tree4a95d1eb4526c347a16266547e80b5c7c8de7080
parent0bc3d9857f571021f7c2ccebe1967f4f87cb3e21 (diff)
downloadcpython-d4ff741e785b598df9737da10831f927fa0eddbb.zip
cpython-d4ff741e785b598df9737da10831f927fa0eddbb.tar.gz
cpython-d4ff741e785b598df9737da10831f927fa0eddbb.tar.bz2
Revert last change. Found an application that was worse off with resize
exact turned on. The tiny space savings wasn't worth the additional time and code.
-rw-r--r--Objects/listobject.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c8a8190..3bda245 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -9,7 +9,7 @@
#endif
static int
-list_resize(PyListObject *self, int newsize, int exact)
+list_resize(PyListObject *self, int newsize)
{
PyObject **items;
size_t _new_size;
@@ -33,10 +33,7 @@ list_resize(PyListObject *self, int newsize, int exact)
* system realloc().
* The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
*/
- if (exact)
- _new_size = newsize;
- else
- _new_size = (newsize>>3) + (self->ob_size < 8 ? 3 : 6) + newsize;
+ _new_size = (newsize >> 3) + (self->ob_size < 8 ? 3 : 6) + newsize;
items = self->ob_item;
if (_new_size <= ((~(size_t)0) / sizeof(PyObject *)))
PyMem_RESIZE(items, PyObject *, _new_size);
@@ -155,7 +152,7 @@ ins1(PyListObject *self, int where, PyObject *v)
return -1;
}
- if (list_resize(self, n+1, 0) == -1)
+ if (list_resize(self, n+1) == -1)
return -1;
if (where < 0) {
@@ -521,13 +518,13 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
if (d < 0) {
memmove(&item[ihigh+d], &item[ihigh],
(a->ob_size - ihigh)*sizeof(PyObject *));
- list_resize(a, a->ob_size + d, 1);
+ list_resize(a, a->ob_size + d);
item = a->ob_item;
}
}
else { /* Insert d items; recycle ihigh-ilow items */
s = a->ob_size;
- if (list_resize(a, s+d, 1) == -1) {
+ if (list_resize(a, s+d) == -1) {
if (recycle != NULL)
PyMem_DEL(recycle);
return -1;
@@ -591,7 +588,7 @@ list_inplace_repeat(PyListObject *self, int n)
return (PyObject *)self;
}
- if (list_resize(self, size*n, 1) == -1)
+ if (list_resize(self, size*n) == -1)
return NULL;
p = size;
@@ -683,7 +680,7 @@ listextend_internal(PyListObject *self, PyObject *b)
}
}
- if (list_resize(self, selflen + blen, 0) == -1) {
+ if (list_resize(self, selflen + blen) == -1) {
Py_DECREF(b);
return -1;
}
@@ -736,7 +733,7 @@ listextend(PyListObject *self, PyObject *b)
}
m = self->ob_size;
mn = m + n;
- if (list_resize(self, mn, 0) == -1)
+ if (list_resize(self, mn) == -1)
goto error;
memset(&(self->ob_item[m]), 0, sizeof(*self->ob_item) * n);
@@ -821,7 +818,7 @@ listpop(PyListObject *self, PyObject *args)
}
v = self->ob_item[i];
if (i == self->ob_size - 1) {
- if (list_resize(self, self->ob_size - 1, 0) == -1)
+ if (list_resize(self, self->ob_size - 1) == -1)
return NULL;
return v;
}
@@ -2520,7 +2517,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
self->ob_size -= slicelength;
- list_resize(self, self->ob_size, 1);
+ list_resize(self, self->ob_size);
for (i = 0; i < slicelength; i++) {
Py_DECREF(garbage[i]);