From 6194cdc7b87d2bbaec5eabfa5a2e81fa2ca5f3d2 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 15 Feb 2007 19:05:25 +0000 Subject: [PATCH] Eliminate a redundent ctor; eliminate one more potential new [0]. llvm-svn: 34313 --- llvm/include/llvm/ADT/BitVector.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h index 94cbf0962140..a6ae1ac80d50 100644 --- a/llvm/include/llvm/ADT/BitVector.h +++ b/llvm/include/llvm/ADT/BitVector.h @@ -72,25 +72,23 @@ public: Bits = NULL; } - /// 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);