From ea0a7586b8615fd39c6b8f5a8a21a1f242129c2f Mon Sep 17 00:00:00 2001 From: costan Date: Fri, 1 Sep 2017 14:36:20 -0700 Subject: [PATCH] Remove confusing and unnecessary if. 12 lines above, there is an "if (!s.ok()) { return s; }" block of code. "s" is never modified between that block and the "if" removed by this CL, so "s.ok()" must be true. The code most likely intended to say "if (!builder->ok())", because the builder->Add() call above can modify the TableBuilder's status, as a side-effect. However, this approach would have required setting "s = builder.status()" in the "else" branch, near the "builder.Abandon()" call. So, removing the "if" outright is simpler than following that line of thought. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=167326229 --- db/builder.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/db/builder.cc b/db/builder.cc index f419882..729f9fd 100644 --- a/db/builder.cc +++ b/db/builder.cc @@ -41,14 +41,10 @@ Status BuildTable(const std::string& dbname, } // Finish and check for builder errors + s = builder->Finish(); if (s.ok()) { - s = builder->Finish(); - if (s.ok()) { - meta->file_size = builder->FileSize(); - assert(meta->file_size > 0); - } - } else { - builder->Abandon(); + meta->file_size = builder->FileSize(); + assert(meta->file_size > 0); } delete builder;