[llvm-commits] CVS: llvm/include/llvm/ADT/BitVector.h

Evan Cheng evan.cheng at apple.com
Thu Feb 15 11:05:45 PST 2007



Changes in directory llvm/include/llvm/ADT:

BitVector.h updated: 1.5 -> 1.6
---
Log message:

Eliminate a redundent ctor; eliminate one more potential new [0].

---
Diffs of the changes:  (+8 -10)

 BitVector.h |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)


Index: llvm/include/llvm/ADT/BitVector.h
diff -u llvm/include/llvm/ADT/BitVector.h:1.5 llvm/include/llvm/ADT/BitVector.h:1.6
--- llvm/include/llvm/ADT/BitVector.h:1.5	Thu Feb 15 13:03:23 2007
+++ llvm/include/llvm/ADT/BitVector.h	Thu Feb 15 13:05:25 2007
@@ -73,24 +73,22 @@
   }
 
   /// BitVector ctor - Creates a bitvector of specified number of bits. All
-  /// bits are initialized to false;
-  BitVector(unsigned s) : Size(s) {
-    Capacity = NumBitWords(s);
-    Bits = new BitWord[Capacity];
-    init_words(Bits, Capacity, false);
-  }
-
-  /// BitVector ctor - Creates a bitvector of specified number of bits. All
   /// bits are initialized to the specified value.
-  BitVector(unsigned s, bool t) : Size(s) {
+  explicit BitVector(unsigned s, bool t = false) : Size(s) {
     Capacity = NumBitWords(s);
     Bits = new BitWord[Capacity];
     init_words(Bits, Capacity, t);
-    clear_unused_bits();
+    if (t)
+      clear_unused_bits();
   }
 
   /// BitVector copy ctor.
   BitVector(const BitVector &RHS) : Size(RHS.size()) {
+    if (Size == 0) {
+      Bits = NULL;
+      return;
+    }
+
     Capacity = NumBitWords(RHS.size());
     Bits = new BitWord[Capacity];
     std::copy(RHS.Bits, &RHS.Bits[Capacity], Bits);






More information about the llvm-commits mailing list