[PATCH] Add SmallDenseSet

Daniel Berlin dberlin at dberlin.org
Wed Mar 18 17:36:56 PDT 2015


This just makes SmallDenseSet a thing, with no actual implementation
changes, just template parameter changes.

My C++ fu is weak on the "how do i make this happen front", so feel free to
point out a better way to do this.

SmallDenseSet is being used in a soon-to-be submitted out of tree patch.

(changed parts were reformatted with clang-format)
---
 include/llvm/ADT/DenseSet.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/llvm/ADT/DenseSet.h b/include/llvm/ADT/DenseSet.h
index d340240..aee825c8 100644
--- a/include/llvm/ADT/DenseSet.h
+++ b/include/llvm/ADT/DenseSet.h
@@ -35,10 +35,12 @@ public:
 }

 /// DenseSet - This implements a dense probed hash-table based set.
-template<typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT> >
+template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>,
+          typename DenseMapT =
+              DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
+                       detail::DenseSetPair<ValueT>>>
 class DenseSet {
-  typedef DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
-                   detail::DenseSetPair<ValueT>> MapTy;
+  typedef DenseMapT MapTy;
   static_assert(sizeof(typename MapTy::value_type) == sizeof(ValueT),
                 "DenseMap buckets unexpectedly large!");
   MapTy TheMap;
@@ -157,6 +159,14 @@ public:
   }
 };

+/// SmallDenseSet - This is the SmallDenseMap version of DenseSet
+template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>,
+          unsigned InlineBuckets = 4>
+using SmallDenseSet =
+    DenseSet<ValueT, ValueInfoT,
+             SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
+                           ValueInfoT, detail::DenseSetPair<ValueT>>>;
+
 } // end namespace llvm

 #endif
--
2.3.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150318/1d595a49/attachment.html>


More information about the llvm-commits mailing list