Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type
[oota-llvm.git] / include / llvm / ADT / BitVector.h
index 3789db4e45d3a6c9e9efa05ff2438a9f8dfd8e3c..8fb538f68fcf5689e93fe91e8f8e6cde02264e62 100644 (file)
@@ -138,8 +138,15 @@ public:
 
   /// all - Returns true if all bits are set.
   bool all() const {
-    // TODO: Optimize this.
-    return count() == size();
+    for (unsigned i = 0; i < Size / BITWORD_SIZE; ++i)
+      if (Bits[i] != ~0UL)
+        return false;
+
+    // If bits remain check that they are ones. The unused bits are always zero.
+    if (unsigned Remainder = Size % BITWORD_SIZE)
+      return Bits[Size / BITWORD_SIZE] == (1UL << Remainder) - 1;
+
+    return true;
   }
 
   /// none - Returns true if none of the bits are set.