diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-12 17:40:22 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-12 17:40:22 +0000 |
commit | ff4a7381f38c8ac1a13ba9b16bc74b66d5dbec2e (patch) | |
tree | 6d2425703f8214b06c5347e995c70ba79e7ca7a3 /lib/Support/FoldingSet.cpp | |
parent | f1ba5d23e432d2f87c1886e63f4d20c845fbe2f1 (diff) | |
download | external_llvm-ff4a7381f38c8ac1a13ba9b16bc74b66d5dbec2e.zip external_llvm-ff4a7381f38c8ac1a13ba9b16bc74b66d5dbec2e.tar.gz external_llvm-ff4a7381f38c8ac1a13ba9b16bc74b66d5dbec2e.tar.bz2 |
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
Diffstat (limited to 'lib/Support/FoldingSet.cpp')
-rw-r--r-- | lib/Support/FoldingSet.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 5f1de4a..6966ec8 100644 --- a/lib/Support/FoldingSet.cpp +++ b/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. |