mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Bug fixes: assignment operator forgot to copy over size; copy ctor forgot to clear unused top bits.
llvm-svn: 34305
This commit is contained in:
parent
9868d8d7db
commit
7ff021d148
@ -86,6 +86,7 @@ public:
|
||||
Capacity = NumBitWords(s);
|
||||
Bits = new BitWord[Capacity];
|
||||
init_words(Bits, Capacity, t);
|
||||
clear_unused_bits();
|
||||
}
|
||||
|
||||
/// BitVector copy ctor.
|
||||
@ -175,6 +176,7 @@ public:
|
||||
init_words(&Bits[OldCapacity], (Capacity-OldCapacity), t);
|
||||
}
|
||||
Size = N;
|
||||
clear_unused_bits();
|
||||
}
|
||||
|
||||
void reserve(unsigned N) {
|
||||
@ -274,17 +276,16 @@ public:
|
||||
const BitVector &operator=(const BitVector &RHS) {
|
||||
if (this == &RHS) return *this;
|
||||
|
||||
unsigned RHSWords = NumBitWords(RHS.size());
|
||||
unsigned NewSize = RHS.size();
|
||||
if (NewSize <= Capacity * BITS_PER_WORD) {
|
||||
Size = RHS.size();
|
||||
unsigned RHSWords = NumBitWords(Size);
|
||||
if (Size > Capacity * BITS_PER_WORD) {
|
||||
std::copy(RHS.Bits, &RHS.Bits[RHSWords], Bits);
|
||||
Size = NewSize;
|
||||
clear_unused_bits();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Grow the bitvector to have enough elements.
|
||||
Capacity = NumBitWords(NewSize);
|
||||
Capacity = NumBitWords(Size);
|
||||
BitWord *NewBits = new BitWord[Capacity];
|
||||
std::copy(RHS.Bits, &RHS.Bits[RHSWords], NewBits);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user