Преглед изворни кода

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
master
cmumford пре 7 година
committed by Victor Costan
родитељ
комит
3da4d8b989
1 измењених фајлова са 3 додато и 8 уклоњено
  1. +3
    -8
      db/log_reader.cc

+ 3
- 8
db/log_reader.cc Прегледај датотеку

@ -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)");
}
}

Loading…
Откажи
Сачувај