[llvm-commits] [llvm] r149187 - /llvm/trunk/include/llvm/ADT/BitVector.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Sat Jan 28 17:29:22 PST 2012
Author: stoklund
Date: Sat Jan 28 19:29:22 2012
New Revision: 149187
URL: http://llvm.org/viewvc/llvm-project?rev=149187&view=rev
Log:
Add a BitVector::reset(BitVector&) method.
The alternative LHS &= ~RHS is way too slow because it creates a
temporary that calls malloc/free.
Modified:
llvm/trunk/include/llvm/ADT/BitVector.h
Modified: llvm/trunk/include/llvm/ADT/BitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=149187&r1=149186&r2=149187&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/BitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/BitVector.h Sat Jan 28 19:29:22 2012
@@ -318,6 +318,16 @@
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());
More information about the llvm-commits
mailing list