From 3da4d8b9899257386aeb5ffa345a6477c62ff7bf Mon Sep 17 00:00:00 2001 From: cmumford Date: Thu, 19 Oct 2017 10:33:42 -0700 Subject: 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 --- db/log_reader.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/db/log_reader.cc b/db/log_reader.cc index a6d3045..48ae863 100644 --- a/db/log_reader.cc +++ b/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)"); } } -- cgit v1.2.1