summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcmumford <cmumford@google.com>2017-10-19 10:33:42 -0700
committerVictor Costan <pwnall@chromium.org>2017-11-03 15:03:44 -0700
commit3da4d8b9899257386aeb5ffa345a6477c62ff7bf (patch)
tree1b074b3c2cf8517232431d92b31dfc46db8c09c3
parent0509414f858ae7c7225e29f3659a709afb324355 (diff)
downloadleveldb-3da4d8b9899257386aeb5ffa345a6477c62ff7bf.tar.gz
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
-rw-r--r--db/log_reader.cc11
1 files 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)");
}
}