aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/BitVector.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/BitVector.h')
-rw-r--r--include/llvm/ADT/BitVector.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h
index 3789db4e45..8f512f5c2c 100644
--- a/include/llvm/ADT/BitVector.h
+++ b/include/llvm/ADT/BitVector.h
@@ -138,8 +138,16 @@ public:
/// all - Returns true if all bits are set.
bool all() const {
- // TODO: Optimize this.
- return count() == size();
+ if (empty())
+ return true;
+
+ for (unsigned i = 0; i < NumBitWords(size()) - 1; ++i)
+ if (Bits[i] != ~0UL)
+ return false;
+
+ // For the last word check that the lower bits are ones. The unused bits are
+ // always zero.
+ return Bits[NumBitWords(size()) - 1] == ~(~0UL << (Size % BITWORD_SIZE));
}
/// none - Returns true if none of the bits are set.