diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-02-15 19:05:25 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-02-15 19:05:25 +0000 |
commit | 334df9d83f7a9f189d21c25a2d32afcd50bd0a9a (patch) | |
tree | 1d8c940ec7fd4b36ce2c2682b002cd40cb050b46 | |
parent | 057f8e084515ca8e10eac5c37c8a9485b844343c (diff) |
Eliminate a redundent ctor; eliminate one more potential new [0].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34313 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/BitVector.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 94cbf09621..a6ae1ac80d 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -73,24 +73,22 @@ public: } /// 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); |