mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
make operator== work with non-equal sized bitvectors, as long as
the extra bits are all zeros. This allows "010" and "010000" to be treated as equal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ca68aaa0e5
commit
886636445d
@ -259,12 +259,23 @@ public:
|
||||
|
||||
// Comparison operators.
|
||||
bool operator==(const BitVector &RHS) const {
|
||||
if (Size != RHS.Size)
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < NumBitWords(size()); ++i)
|
||||
unsigned ThisWords = NumBitWords(size());
|
||||
unsigned RHSWords = NumBitWords(RHS.size());
|
||||
unsigned i;
|
||||
for (i = 0; i != std::min(ThisWords, RHSWords); ++i)
|
||||
if (Bits[i] != RHS.Bits[i])
|
||||
return false;
|
||||
|
||||
// Verify that any extra words are all zeros.
|
||||
if (i != ThisWords) {
|
||||
for (; i != ThisWords; ++i)
|
||||
if (Bits[i])
|
||||
return false;
|
||||
} else if (i != RHSWords) {
|
||||
for (; i != RHSWords; ++i)
|
||||
if (RHS.Bits[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user