From c9c935923e7de16ac3c7341d385c743083ee4001 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Wed, 29 Oct 2014 11:21:51 -0700 Subject: [PATCH] Move the check to the beginning of the loop in VersionEdit::EncodeTo() --- db/version_edit.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/version_edit.cc b/db/version_edit.cc index 32e49fe95..4a6506c7d 100644 --- a/db/version_edit.cc +++ b/db/version_edit.cc @@ -98,6 +98,9 @@ bool VersionEdit::EncodeTo(std::string* dst) const { for (size_t i = 0; i < new_files_.size(); i++) { const FileMetaData& f = new_files_[i].second; + if (!f.smallest.Valid() || !f.largest.Valid()) { + return false; + } if (f.fd.GetPathId() == 0) { // Use older format to make sure user can roll back the build if they // don't config multiple DB paths. @@ -111,9 +114,6 @@ bool VersionEdit::EncodeTo(std::string* dst) const { PutVarint32(dst, f.fd.GetPathId()); } PutVarint64(dst, f.fd.GetFileSize()); - if (!f.smallest.Valid() || !f.largest.Valid()) { - return false; - } PutLengthPrefixedSlice(dst, f.smallest.Encode()); PutLengthPrefixedSlice(dst, f.largest.Encode()); PutVarint64(dst, f.smallest_seqno);