summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/BitVector.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-29 01:29:22 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-29 01:29:22 +0000
commit19de016955f744cf2466fadcd28e9bf8847dd260 (patch)
tree3da52c6bff3b0bf703adbc2aa870769098f64525 /include/llvm/ADT/BitVector.h
parent5fef01db01592903d3a22701b598fb6a69265c53 (diff)
downloadllvm-19de016955f744cf2466fadcd28e9bf8847dd260.tar.gz
llvm-19de016955f744cf2466fadcd28e9bf8847dd260.tar.bz2
llvm-19de016955f744cf2466fadcd28e9bf8847dd260.tar.xz
Add a BitVector::reset(BitVector&) method.
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
Diffstat (limited to 'include/llvm/ADT/BitVector.h')
-rw-r--r--include/llvm/ADT/BitVector.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h
index 7d7afc347e..d5f247bb22 100644
--- a/include/llvm/ADT/BitVector.h
+++ b/include/llvm/ADT/BitVector.h
@@ -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());