avoid unnecessary memory copy

This commit is contained in:
wzk784533 2020-07-11 13:44:11 +08:00
parent 5bd5f0f67a
commit 28602d3625

View File

@ -30,11 +30,14 @@ Status BuildTable(const std::string& dbname, Env* env, const Options& options,
TableBuilder* builder = new TableBuilder(options, file); TableBuilder* builder = new TableBuilder(options, file);
meta->smallest.DecodeFrom(iter->key()); meta->smallest.DecodeFrom(iter->key());
Slice key;
for (; iter->Valid(); iter->Next()) { for (; iter->Valid(); iter->Next()) {
Slice key = iter->key(); key = iter->key();
meta->largest.DecodeFrom(key);
builder->Add(key, iter->value()); builder->Add(key, iter->value());
} }
if(!key.empty()) {
meta->largest.DecodeFrom(key);
}
// Finish and check for builder errors // Finish and check for builder errors
s = builder->Finish(); s = builder->Finish();