@@ -145,12 +145,10 @@ _capacity <<= 1; if (_capacity < MIN_CAPACITY) _capacity = MIN_CAPACITY; - _minCapacity = _capacity; - _buckets = [self allocMemoryWithSize: sizeof(*_buckets) count: _capacity]; memset(_buckets, 0, _capacity * sizeof(*_buckets)); @@ -244,12 +242,10 @@ } @catch (id e) { [copy release]; @throw e; } - copy->_minCapacity = MIN_CAPACITY; - return copy; } - (size_t)count { @@ -309,11 +305,15 @@ else if (fullness <= 1) capacity = _capacity >> 1; else return; - if (capacity < _capacity && capacity < _minCapacity) + /* + * Don't downsize if we have an initial capacity or if we would fall + * below the minimum capacity. + */ + if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY) return; buckets = [self allocMemoryWithSize: sizeof(*buckets) count: capacity];