aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ADT/FoldingSet.h6
-rw-r--r--lib/Support/FoldingSet.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h
index 6b0463365a..1a9407108f 100644
--- a/include/llvm/ADT/FoldingSet.h
+++ b/include/llvm/ADT/FoldingSet.h
@@ -117,7 +117,7 @@ private:
unsigned NumNodes;
public:
- FoldingSetImpl();
+ FoldingSetImpl(unsigned Log2InitSize = 6);
virtual ~FoldingSetImpl();
// Forward declaration.
@@ -229,6 +229,10 @@ private:
}
public:
+ FoldingSet(unsigned Log2InitSize = 6)
+ : FoldingSetImpl(Log2InitSize)
+ {}
+
/// GetOrInsertNode - If there is an existing simple Node exactly
/// equal to the specified node, return it. Otherwise, insert 'N' and
/// return it instead.
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp
index 1bd20145f4..a569e1a79d 100644
--- a/lib/Support/FoldingSet.cpp
+++ b/lib/Support/FoldingSet.cpp
@@ -151,8 +151,10 @@ static void **GetBucketFor(const FoldingSetImpl::NodeID &ID,
//===----------------------------------------------------------------------===//
// FoldingSetImpl Implementation
-FoldingSetImpl::FoldingSetImpl() : NumNodes(0) {
- NumBuckets = 64;
+FoldingSetImpl::FoldingSetImpl(unsigned Log2InitSize) : NumNodes(0) {
+ assert(5 < Log2InitSize && Log2InitSize < 32 &&
+ "Initial hash table size out of range");
+ NumBuckets = 1 << Log2InitSize;
Buckets = new void*[NumBuckets];
memset(Buckets, 0, NumBuckets*sizeof(void*));
}