Use initializer list for VersionSet

Summary: initialiszer list is fasteri/preferable because it can straightaway call the constructor for this object, otherwise it will be created first and then again initialized. Although gain may not be much in this case because files_ is just a pointer and not a complex object, this is recommended practice.

Test Plan: make all check

Reviewers: dhruba, haobo

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D12519
This commit is contained in:
Mayank Agarwal 2013-08-23 15:41:18 -07:00
parent 573844807c
commit b1074ac24f

View File

@ -397,6 +397,7 @@ static bool NewestFirstBySeqNo(FileMetaData* a, FileMetaData* b) {
Version::Version(VersionSet* vset, uint64_t version_number) Version::Version(VersionSet* vset, uint64_t version_number)
: vset_(vset), next_(this), prev_(this), refs_(0), : vset_(vset), next_(this), prev_(this), refs_(0),
files_(new std::vector<FileMetaData*>[vset->NumberLevels()]),
files_by_size_(vset->NumberLevels()), files_by_size_(vset->NumberLevels()),
next_file_to_compact_by_size_(vset->NumberLevels()), next_file_to_compact_by_size_(vset->NumberLevels()),
file_to_compact_(nullptr), file_to_compact_(nullptr),
@ -405,7 +406,6 @@ Version::Version(VersionSet* vset, uint64_t version_number)
compaction_level_(vset->NumberLevels()), compaction_level_(vset->NumberLevels()),
offset_manifest_file_(0), offset_manifest_file_(0),
version_number_(version_number) { version_number_(version_number) {
files_ = new std::vector<FileMetaData*>[vset->NumberLevels()];
} }
void Version::Get(const ReadOptions& options, void Version::Get(const ReadOptions& options,