Kaynağa Gözat

Deleted unused assignments in Reader.

Deleted two unused assignments:

1. offset_in_block in Reader::SkipToInitialBlock().
2. in_fragmented_record in Reader::ReadRecord().

Reasons for the change:
1. offset_in_block is not read again after the if condition.
2. The kFullRecordType switch branch returns, so
   in_fragmented_record isn't read again.
3. The kFirstType switch branch sets in_fragmented_record to
   true after the if, so the write in the if is ignored.

Change contributed by @C0deAi on GitHub.

This fixes https://github.com/google/leveldb/issues/517

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172763897
main
cmumford 7 yıl önce
işlemeyi yapan: Victor Costan
ebeveyn
işleme
3da4d8b989
1 değiştirilmiş dosya ile 3 ekleme ve 8 silme
  1. +3
    -8
      db/log_reader.cc

+ 3
- 8
db/log_reader.cc Dosyayı Görüntüle

@ -34,12 +34,11 @@ Reader::~Reader() {
}
bool Reader::SkipToInitialBlock() {
size_t offset_in_block = initial_offset_ % kBlockSize;
const size_t offset_in_block = initial_offset_ % kBlockSize;
uint64_t block_start_location = initial_offset_ - offset_in_block;
// Don't search a block if we'd be in the trailer
if (offset_in_block > kBlockSize - 6) {
offset_in_block = 0;
block_start_location += kBlockSize;
}
@ -99,9 +98,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) {
// it could emit an empty kFirstType record at the tail end
// of a block followed by a kFullType or kFirstType record
// at the beginning of the next block.
if (scratch->empty()) {
in_fragmented_record = false;
} else {
if (!scratch->empty()) {
ReportCorruption(scratch->size(), "partial record without end(1)");
}
}
@ -117,9 +114,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) {
// it could emit an empty kFirstType record at the tail end
// of a block followed by a kFullType or kFirstType record
// at the beginning of the next block.
if (scratch->empty()) {
in_fragmented_record = false;
} else {
if (!scratch->empty()) {
ReportCorruption(scratch->size(), "partial record without end(2)");
}
}

Yükleniyor…
İptal
Kaydet