VersionBuilder: Erase with iterators for better performance

Summary: Closes https://github.com/facebook/rocksdb/pull/3007

Differential Revision: D6077701

Pulled By: yiwu-arbug

fbshipit-source-id: a6fd5b8a23f4feb1660b9ce027f651a7e90352b3
This commit is contained in:
Changli Gao 2017-10-17 09:58:24 -07:00 committed by Facebook Github Bot
parent f7843f30a8
commit b8cea7cc27

View file

@ -274,11 +274,12 @@ class VersionBuilder::Rep {
auto exising = levels_[level].added_files.find(number);
if (exising != levels_[level].added_files.end()) {
UnrefFile(exising->second);
levels_[level].added_files.erase(number);
levels_[level].added_files.erase(exising);
}
} else {
if (invalid_levels_[level].count(number) > 0) {
invalid_levels_[level].erase(number);
auto exising = invalid_levels_[level].find(number);
if (exising != invalid_levels_[level].end()) {
invalid_levels_[level].erase(exising);
} else {
// Deleting an non-existing file on invalid level.
has_invalid_levels_ = true;