ObjFW  Diff

Differences From Artifact [212223cd50]:

To Artifact [1f61a324ed]:


143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
143
144
145
146
147
148
149


150
151
152
153
154
155
156







-
-







		for (_capacity = 1; _capacity < capacity; _capacity <<= 1);
		if (capacity * 8 / _capacity >= 6)
			_capacity <<= 1;

		if (_capacity < MIN_CAPACITY)
			_capacity = MIN_CAPACITY;

		_minCapacity = _capacity;

		_buckets = [self allocMemoryWithSize: sizeof(*_buckets)
					       count: _capacity];

		memset(_buckets, 0, _capacity * sizeof(*_buckets));

		if (of_hash_seed != 0)
#if defined(HAVE_ARC4RANDOM)
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
240
241
242
243
244
245
246


247
248
249
250
251
252
253







-
-







					     hash: OF_ROR(_buckets[i]->hash,
						       _rotate)];
	} @catch (id e) {
		[copy release];
		@throw e;
	}

	copy->_minCapacity = MIN_CAPACITY;

	return copy;
}

- (size_t)count
{
	return _count;
}
307
308
309
310
311
312
313




314

315
316
317
318
319
320
321
303
304
305
306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321







+
+
+
+
-
+







	if (fullness >= 6)
		capacity = _capacity << 1;
	else if (fullness <= 1)
		capacity = _capacity >> 1;
	else
		return;

	/*
	 * Don't downsize if we have an initial capacity or if we would fall
	 * below the minimum capacity.
	 */
	if (capacity < _capacity && capacity < _minCapacity)
	if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY)
		return;

	buckets = [self allocMemoryWithSize: sizeof(*buckets)
				      count: capacity];

	for (i = 0; i < capacity; i++)
		buckets[i] = NULL;