Refactored PieceStatMan::updatePieceStats().

pull/1/head
Tatsuhiro Tsujikawa 2010-12-07 01:08:11 +09:00
parent 829803d4f5
commit 9103fb6105
1 changed files with 7 additions and 5 deletions

View File

@ -145,11 +145,13 @@ void PieceStatMan::updatePieceStats(const unsigned char* newBitfield,
const size_t nbits = pieceStats_.size(); const size_t nbits = pieceStats_.size();
assert(nbits <= newBitfieldLength*8); assert(nbits <= newBitfieldLength*8);
for(size_t i = 0; i < nbits; ++i) { for(size_t i = 0; i < nbits; ++i) {
if(bitfield::test(newBitfield, nbits, i) && bool inNew = bitfield::test(newBitfield, nbits, i);
!bitfield::test(oldBitfield, nbits, i)) { bool inOld = bitfield::test(oldBitfield, nbits, i);
pieceStats_[i]->addCount(); if(inNew) {
} else if(!bitfield::test(newBitfield, nbits, i) && if(!inOld) {
bitfield::test(oldBitfield, nbits, i)) { pieceStats_[i]->addCount();
}
} else if(inOld) {
pieceStats_[i]->subCount(); pieceStats_[i]->subCount();
} }
} }