[PATCH] D20930: Adding reserve and capacity methods to FoldingSet
Ben Craig via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 06:24:06 PDT 2016
bcraig added inline comments.
================
Comment at: lib/Support/FoldingSet.cpp:304
@@ +303,3 @@
+void FoldingSetImpl::GrowHashTable() {
+ GrowHashTable(NumBuckets * 2);
+}
----------------
bkramer wrote:
> So the capacity() is NumBuckets*2 and we're growing to that capacity? I'm confused. Either one of those interfaces is wrong or we're just missing docs.
GrowHashTable() is private. It has historically been called without a parameter to double the size of the hash table.
GrowHashTable(unsigned NewBucketCount) is also private. It operates in terms of bucket count.
reserve and capacity are public. They operate in terms of elements.
FoldingSet allows for twice as many elements as buckets, both before and after this patch.
This means that the math for doubling the size of the hash table (NumBuckets * 2) is the same math required to convert from buckets to element capacity (NumBuckets * 2).
http://reviews.llvm.org/D20930
More information about the llvm-commits
mailing list