[llvm-commits] [llvm] r54687 - /llvm/trunk/lib/Support/FoldingSet.cpp
Dan Gohman
gohman at apple.com
Tue Aug 12 10:41:12 PDT 2008
Author: djg
Date: Tue Aug 12 12:40:22 2008
New Revision: 54687
URL: http://llvm.org/viewvc/llvm-project?rev=54687&view=rev
Log:
Avoid repeatedly reallocating the FoldingSetNodeID when searching
through multiple nodes in a bucket.
Modified:
llvm/trunk/lib/Support/FoldingSet.cpp
Modified: llvm/trunk/lib/Support/FoldingSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=54687&r1=54686&r2=54687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FoldingSet.cpp (original)
+++ llvm/trunk/lib/Support/FoldingSet.cpp Tue Aug 12 12:40:22 2008
@@ -232,6 +232,7 @@
Buckets[NumBuckets] = reinterpret_cast<void*>(-1);
// Walk the old buckets, rehashing nodes into their new place.
+ FoldingSetNodeID ID;
for (unsigned i = 0; i != OldNumBuckets; ++i) {
void *Probe = OldBuckets[i];
if (!Probe) continue;
@@ -241,9 +242,9 @@
NodeInBucket->SetNextInBucket(0);
// Insert the node into the new bucket, after recomputing the hash.
- FoldingSetNodeID ID;
GetNodeProfile(ID, NodeInBucket);
InsertNode(NodeInBucket, GetBucketFor(ID, Buckets, NumBuckets));
+ ID.clear();
}
}
@@ -262,13 +263,14 @@
InsertPos = 0;
+ FoldingSetNodeID OtherID;
while (Node *NodeInBucket = GetNextPtr(Probe)) {
- FoldingSetNodeID OtherID;
GetNodeProfile(OtherID, NodeInBucket);
if (OtherID == ID)
return NodeInBucket;
Probe = NodeInBucket->getNextInBucket();
+ OtherID.clear();
}
// Didn't find the node, return null with the bucket as the InsertPos.
More information about the llvm-commits
mailing list