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