Mercurial > dedupe
diff FastBitDecoder.cpp @ 49:f8d0ea827db3
Use BitArray.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 10 Sep 2012 23:59:46 +0200 |
| parents | 877327e9061a |
| children | c8111de2e0bb |
line wrap: on
line diff
--- a/FastBitDecoder.cpp Mon Sep 10 23:59:25 2012 +0200 +++ b/FastBitDecoder.cpp Mon Sep 10 23:59:46 2012 +0200 @@ -6,7 +6,7 @@ #include <cassert> -unsigned char FastBitDecoder::getPaddedChar(const QBitArray& bits, uint offset) +unsigned char FastBitDecoder::getPaddedChar(const BitArray& bits, uint offset) { unsigned char retVal = 0; size_t n = std::min(8u, bits.size() - offset); @@ -16,14 +16,14 @@ return retVal; } -QBitArray FastBitDecoder::removeFirst(const QBitArray& bits) +BitArray FastBitDecoder::removeFirst(const BitArray& bits) { size_t N = bits.size(); assert(N - 8 > 0); size_t n = N - 8; - QBitArray retVal(n); + BitArray retVal(n); for (size_t i = 0; i < n; ++i) { - retVal.setBit(i, bits.at(i + 8)); + retVal.setBit(i, bits.testBit(i + 8)); } return retVal; } @@ -58,10 +58,10 @@ } -FastBitDecoder::FastBitDecoder(const QMap<QString, QBitArray>& encoder) +FastBitDecoder::FastBitDecoder(const QMap<QString, BitArray>& encoder) { blank(); - for(QMap<QString, QBitArray>::const_iterator it = encoder.begin(); + for(QMap<QString, BitArray>::const_iterator it = encoder.begin(); it != encoder.end(); ++it) { insert(it.value(), it.key()); } @@ -69,7 +69,7 @@ } -void FastBitDecoder::insert(const QBitArray& key, const QString& value) +void FastBitDecoder::insert(const BitArray& key, const QString& value) { unsigned char l = getPaddedChar(key); if (key.size() <= 8) { @@ -85,7 +85,7 @@ } -uint FastBitDecoder::decode(QString& resString, const QBitArray& bits, uint offset) const +uint FastBitDecoder::decode(QString& resString, const BitArray& bits, uint offset) const { unsigned char l = getPaddedChar(bits, offset); if (data[l]) {
