Skip to content

Commit 8478f38

Browse files
committed
During benchmarking, I see excessive use of vector.reserve().
Summary: This code path can potentially accumulate multiple important_files for level 0. But for other levels, it should have only one file in the important_files, so it is ok not to reserve excessive space, is it not? Test Plan: make check Reviewers: haobo Reviewed By: haobo CC: reconnect.grayhat, leveldb Differential Revision: https://reviews.facebook.net/D14349
1 parent e60dde7 commit 8478f38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

db/version_set.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ void Version::Get(const ReadOptions& options,
458458
// Get the list of files to search in this level
459459
FileMetaData* const* files = &files_[level][0];
460460
important_files.clear();
461-
important_files.reserve(num_files);
461+
if (level == 0) {
462+
important_files.reserve(num_files);
463+
}
462464

463465
// Some files may overlap each other. We find
464466
// all files that overlap user_key and process them in order from

0 commit comments

Comments
 (0)