llvm.org GIT mirror llvm / ee4bd9a
Avoid repeatedly reallocating the FoldingSetNodeID when searching through multiple nodes in a bucket. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54687 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
1 changed file(s) with 4 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
231231 Buckets[NumBuckets] = reinterpret_cast(-1);
232232
233233 // Walk the old buckets, rehashing nodes into their new place.
234 FoldingSetNodeID ID;
234235 for (unsigned i = 0; i != OldNumBuckets; ++i) {
235236 void *Probe = OldBuckets[i];
236237 if (!Probe) continue;
240241 NodeInBucket->SetNextInBucket(0);
241242
242243 // Insert the node into the new bucket, after recomputing the hash.
243 FoldingSetNodeID ID;
244244 GetNodeProfile(ID, NodeInBucket);
245245 InsertNode(NodeInBucket, GetBucketFor(ID, Buckets, NumBuckets));
246 ID.clear();
246247 }
247248 }
248249
261262
262263 InsertPos = 0;
263264
265 FoldingSetNodeID OtherID;
264266 while (Node *NodeInBucket = GetNextPtr(Probe)) {
265 FoldingSetNodeID OtherID;
266267 GetNodeProfile(OtherID, NodeInBucket);
267268 if (OtherID == ID)
268269 return NodeInBucket;
269270
270271 Probe = NodeInBucket->getNextInBucket();
272 OtherID.clear();
271273 }
272274
273275 // Didn't find the node, return null with the bucket as the InsertPos.