Move the check to the beginning of the loop in VersionEdit::EncodeTo()

This commit is contained in:
Yueh-Hsuan Chiang 2014-10-29 11:21:51 -07:00
parent 2110e43a5a
commit c9c935923e

View File

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