Add a BitVector::reset(BitVector&) method.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 29 Jan 2012 01:29:22 +0000 (01:29 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 29 Jan 2012 01:29:22 +0000 (01:29 +0000)
The alternative LHS &= ~RHS is way too slow because it creates a
temporary that calls malloc/free.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149187 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/BitVector.h

index 7d7afc347ebe9a19102bc599fc6ac39c6eea85e3..d5f247bb22cb451194447b8e58eb7d17183e6067 100644 (file)
@@ -318,6 +318,16 @@ public:
     return *this;
   }
 
+  // reset - Reset bits that are set in RHS. Same as *this &= ~RHS.
+  BitVector &reset(const BitVector &RHS) {
+    unsigned ThisWords = NumBitWords(size());
+    unsigned RHSWords  = NumBitWords(RHS.size());
+    unsigned i;
+    for (i = 0; i != std::min(ThisWords, RHSWords); ++i)
+      Bits[i] &= ~RHS.Bits[i];
+    return *this;
+  }
+
   BitVector &operator|=(const BitVector &RHS) {
     if (size() < RHS.size())
       resize(RHS.size());