void *DictImpl::getMutable( bits_t *bits, void const *keyData ) const { // [pzion 20111017] Only maybe resize when our node count // is zero or a power of two minus one if ( (bits->nodeCount & (bits->nodeCount - 1)) == 0 ) maybeResize( bits ); size_t keyHash = m_keyImpl->hash( keyData ); size_t bucketIndex = keyHash & (bits->bucketCount - 1); bucket_t *bucket = &bits->buckets[bucketIndex]; void *result = getMutable( bits, bucket, keyData, keyHash ); return result; }
void* PointerSetBase::addItem(void* obj, HashFunction hashFunc) { if (!validValue(obj)) { return NULL; } size_t objHash = hashFunc(obj); size_t pos = probeItems(obj, objHash, mItems, mShift); DCHECK(pos < (1U << mShift)); void* result = mItems[pos]; if (validValue(result)) { // Simple replacement. DCHECK(result == obj); return result; } mItems[pos] = obj; mCount++; if (result != TOMBSTONE) { // No need to resize when replacing tombstone. maybeResize(hashFunc); } return NULL; }