Commit b77debf7 authored by Robert Bradshaw's avatar Robert Bradshaw

Re-introduce shrinking and avoiding re-allocation for cython.array

This partially reverts 65d3b977,
but is more correct.

Closes #1492
parent 0101be0f
......@@ -121,7 +121,7 @@ static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
void *items = (void*) self->data.ob_item;
Py_ssize_t newsize;
if (n < self->ob_size) {
if (n < self->allocated && n*4 > self->allocated) {
self->ob_size = n;
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment