[llvm-commits] [llvm] r164823 - /llvm/trunk/include/llvm/ADT/SparseBitVector.h

Benjamin Kramer benny.kra at googlemail.com
Fri Sep 28 08:36:41 PDT 2012


Author: d0k
Date: Fri Sep 28 10:36:41 2012
New Revision: 164823

URL: http://llvm.org/viewvc/llvm-project?rev=164823&view=rev
Log:
Provide malloc-free sentinels for the SparseBitVector internals.

Modified:
    llvm/trunk/include/llvm/ADT/SparseBitVector.h

Modified: llvm/trunk/include/llvm/ADT/SparseBitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseBitVector.h?rev=164823&r1=164822&r2=164823&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SparseBitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SparseBitVector.h Fri Sep 28 10:36:41 2012
@@ -262,6 +262,22 @@
   }
 };
 
+template <unsigned ElementSize>
+struct ilist_traits<SparseBitVectorElement<ElementSize> >
+  : public ilist_default_traits<SparseBitVectorElement<ElementSize> > {
+  typedef SparseBitVectorElement<ElementSize> Element;
+
+  Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
+  static void destroySentinel(Element *) {}
+
+  Element *provideInitialHead() const { return createSentinel(); }
+  Element *ensureHead(Element *) const { return createSentinel(); }
+  static void noteHead(Element *, Element *) {}
+
+private:
+  mutable ilist_half_node<Element> Sentinel;
+};
+
 template <unsigned ElementSize = 128>
 class SparseBitVector {
   typedef ilist<SparseBitVectorElement<ElementSize> > ElementList;





More information about the llvm-commits mailing list