mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
minor cleanups. Fix off-by-one in accounting the number of nodes when the
table grows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0331524555
commit
b85210f508
@ -181,7 +181,7 @@ void FoldingSetImpl::GrowHashTable() {
|
|||||||
for (unsigned i = 0; i != OldNumBuckets; ++i) {
|
for (unsigned i = 0; i != OldNumBuckets; ++i) {
|
||||||
void *Probe = OldBuckets[i];
|
void *Probe = OldBuckets[i];
|
||||||
if (!Probe) continue;
|
if (!Probe) continue;
|
||||||
while (Node *NodeInBucket = GetNextPtr(Probe, OldBuckets, OldNumBuckets)){
|
while (Node *NodeInBucket = GetNextPtr(Probe, OldBuckets, OldNumBuckets)) {
|
||||||
// Figure out the next link, remove NodeInBucket from the old link.
|
// Figure out the next link, remove NodeInBucket from the old link.
|
||||||
Probe = NodeInBucket->getNextInBucket();
|
Probe = NodeInBucket->getNextInBucket();
|
||||||
NodeInBucket->SetNextInBucket(0);
|
NodeInBucket->SetNextInBucket(0);
|
||||||
@ -224,14 +224,15 @@ FoldingSetImpl::Node *FoldingSetImpl::FindNodeOrInsertPos(const NodeID &ID,
|
|||||||
/// is not already in the map. InsertPos must be obtained from
|
/// is not already in the map. InsertPos must be obtained from
|
||||||
/// FindNodeOrInsertPos.
|
/// FindNodeOrInsertPos.
|
||||||
void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
|
void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
|
||||||
++NumNodes;
|
|
||||||
// Do we need to grow the hashtable?
|
// Do we need to grow the hashtable?
|
||||||
if (NumNodes > NumBuckets*2) {
|
if (NumNodes+1 > NumBuckets*2) {
|
||||||
GrowHashTable();
|
GrowHashTable();
|
||||||
NodeID ID;
|
NodeID ID;
|
||||||
GetNodeProfile(ID, N);
|
GetNodeProfile(ID, N);
|
||||||
InsertPos = GetBucketFor(ID, Buckets, NumBuckets);
|
InsertPos = GetBucketFor(ID, Buckets, NumBuckets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++NumNodes;
|
||||||
|
|
||||||
/// The insert position is actually a bucket pointer.
|
/// The insert position is actually a bucket pointer.
|
||||||
void **Bucket = static_cast<void**>(InsertPos);
|
void **Bucket = static_cast<void**>(InsertPos);
|
||||||
@ -243,7 +244,7 @@ void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
|
|||||||
if (Next == 0)
|
if (Next == 0)
|
||||||
Next = Bucket;
|
Next = Bucket;
|
||||||
|
|
||||||
// Set the nodes next pointer, and make the bucket point to the node.
|
// Set the node's next pointer, and make the bucket point to the node.
|
||||||
N->SetNextInBucket(Next);
|
N->SetNextInBucket(Next);
|
||||||
*Bucket = N;
|
*Bucket = N;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user