summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FoldingSet.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-12 17:40:22 +0000
committerDan Gohman <gohman@apple.com>2008-08-12 17:40:22 +0000
commitbe5e69ed37d640a2dc4da3be2a87f4376d6a60f8 (patch)
tree8f0c9ba4b7cf414ab780a680b9ca0f03c819af33 /llvm/lib/Support/FoldingSet.cpp
parent0d29ae085b37a02cae3dd27a63d7ab8e5ccc2925 (diff)
downloadbcm5719-llvm-be5e69ed37d640a2dc4da3be2a87f4376d6a60f8.tar.gz
bcm5719-llvm-be5e69ed37d640a2dc4da3be2a87f4376d6a60f8.zip
Avoid repeatedly reallocating the FoldingSetNodeID when searching
through multiple nodes in a bucket. llvm-svn: 54687
Diffstat (limited to 'llvm/lib/Support/FoldingSet.cpp')
-rw-r--r--llvm/lib/Support/FoldingSet.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index 5f1de4a657f..6966ec8a153 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/lib/Support/FoldingSet.cpp
@@ -232,6 +232,7 @@ void FoldingSetImpl::GrowHashTable() {
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 @@ void FoldingSetImpl::GrowHashTable() {
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 @@ FoldingSetImpl::Node
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.
OpenPOWER on IntegriCloud