| 2376 | /////////////////////////////////////////////////////////////////////////////// |
| 2377 | |
| 2378 | BucketPrunerPair* BucketPrunerMap::addPair(const PrunerPayload& payload, PxU32 coreIndex, PxU32 timeStamp) |
| 2379 | { |
| 2380 | PxU32 hashValue = hash(payload) & mMask; |
| 2381 | |
| 2382 | { |
| 2383 | BucketPrunerPair* PX_RESTRICT p = findPair(payload, hashValue); |
| 2384 | if(p) |
| 2385 | { |
| 2386 | PX_ASSERT(p->mCoreIndex==coreIndex); |
| 2387 | PX_ASSERT(p->mTimeStamp==timeStamp); |
| 2388 | return p; // Persistent pair |
| 2389 | } |
| 2390 | } |
| 2391 | |
| 2392 | // This is a new pair |
| 2393 | if(mNbActivePairs >= mHashSize) |
| 2394 | { |
| 2395 | // Get more entries |
| 2396 | mHashSize = Ps::nextPowerOfTwo(mNbActivePairs+1); |
| 2397 | mMask = mHashSize-1; |
| 2398 | |
| 2399 | reallocPairs(); |
| 2400 | |
| 2401 | // Recompute hash value with new hash size |
| 2402 | hashValue = hash(payload) & mMask; // ### redundant hash computation here? |
| 2403 | } |
| 2404 | |
| 2405 | BucketPrunerPair* PX_RESTRICT p = &mActivePairs[mNbActivePairs]; |
| 2406 | p->mPayload = payload; |
| 2407 | p->mCoreIndex = coreIndex; |
| 2408 | p->mTimeStamp = timeStamp; |
| 2409 | mNext[mNbActivePairs] = mHashTable[hashValue]; |
| 2410 | mHashTable[hashValue] = mNbActivePairs++; |
| 2411 | return p; |
| 2412 | } |
| 2413 | |
| 2414 | /////////////////////////////////////////////////////////////////////////////// |
| 2415 |
no test coverage detected