/// \brief Defines facilities for reading and writing on-disk hash tables.
///
//===----------------------------------------------------------------------===//
-#ifndef LLVM_SUPPORT_ON_DISK_HASH_TABLE_H
-#define LLVM_SUPPORT_ON_DISK_HASH_TABLE_H
+#ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H
+#define LLVM_SUPPORT_ONDISKHASHTABLE_H
#include "llvm/Support/Allocator.h"
#include "llvm/Support/AlignOf.h"
/// };
/// \endcode
template <typename Info> class OnDiskChainedHashTableGenerator {
- typedef typename Info::offset_type offset_type;
- offset_type NumBuckets;
- offset_type NumEntries;
- llvm::BumpPtrAllocator BA;
-
/// \brief A single item in the hash table.
class Item {
public:
Item(typename Info::key_type_ref Key, typename Info::data_type_ref Data,
Info &InfoObj)
- : Key(Key), Data(Data), Next(0), Hash(InfoObj.ComputeHash(Key)) {}
+ : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
};
+ typedef typename Info::offset_type offset_type;
+ offset_type NumBuckets;
+ offset_type NumEntries;
+ llvm::SpecificBumpPtrAllocator<Item> BA;
+
/// \brief A linked list of values in a particular hash bucket.
class Bucket {
public:
for (size_t I = 0; I < NumBuckets; ++I)
for (Item *E = Buckets[I].Head; E;) {
Item *N = E->Next;
- E->Next = 0;
+ E->Next = nullptr;
insert(NewBuckets, NewSize, E);
E = N;
}
++NumEntries;
if (4 * NumEntries >= 3 * NumBuckets)
resize(NumBuckets * 2);
- insert(Buckets, NumBuckets,
- new (BA.Allocate<Item>()) Item(Key, Data, InfoObj));
+ insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
}
/// \brief Emit the table to Out, which must not be at offset 0.
Info *InfoObj;
public:
- iterator() : Data(0), Len(0) {}
+ iterator() : Data(nullptr), Len(0) {}
iterator(const internal_key_type K, const unsigned char *D, offset_type L,
Info *InfoObj)
: Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
: Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries),
InfoObj(InfoObj) {}
key_iterator()
- : Ptr(0), NumItemsInBucketLeft(0), NumEntriesLeft(0), InfoObj(0) {}
+ : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0),
+ InfoObj(0) {}
friend bool operator==(const key_iterator &X, const key_iterator &Y) {
return X.NumEntriesLeft == Y.NumEntriesLeft;
: Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries),
InfoObj(InfoObj) {}
data_iterator()
- : Ptr(0), NumItemsInBucketLeft(0), NumEntriesLeft(0), InfoObj(0) {}
+ : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0),
+ InfoObj(nullptr) {}
bool operator==(const data_iterator &X) const {
return X.NumEntriesLeft == NumEntriesLeft;
} // end namespace llvm
-#endif // LLVM_SUPPORT_ON_DISK_HASH_TABLE_H
+#endif