Replace named comparator struct with lambda (#5768)

Summary:
Tiny code mod: replace a named comparator struct with anonymous lambda.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5768

Differential Revision: D17185141

Pulled By: riversand963

fbshipit-source-id: fabe367649931c33a39ad035dc707d2efc3ad5fc
main
Yanqin Jin 5 years ago committed by Facebook Github Bot
parent cdb6334e68
commit 38b17ecd0e
  1. 22
      db/wal_manager.cc

@ -280,17 +280,6 @@ void WalManager::ArchiveWALFile(const std::string& fname, uint64_t number) {
s.ToString().c_str());
}
namespace {
struct CompareLogByPointer {
bool operator()(const std::unique_ptr<LogFile>& a,
const std::unique_ptr<LogFile>& b) {
LogFileImpl* a_impl = static_cast_with_check<LogFileImpl, LogFile>(a.get());
LogFileImpl* b_impl = static_cast_with_check<LogFileImpl, LogFile>(b.get());
return *a_impl < *b_impl;
}
};
}
Status WalManager::GetSortedWalsOfType(const std::string& path,
VectorLogPtr& log_files,
WalFileType log_type) {
@ -341,8 +330,15 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
new LogFileImpl(number, log_type, sequence, size_bytes)));
}
}
CompareLogByPointer compare_log_files;
std::sort(log_files.begin(), log_files.end(), compare_log_files);
std::sort(
log_files.begin(), log_files.end(),
[](const std::unique_ptr<LogFile>& a, const std::unique_ptr<LogFile>& b) {
LogFileImpl* a_impl =
static_cast_with_check<LogFileImpl, LogFile>(a.get());
LogFileImpl* b_impl =
static_cast_with_check<LogFileImpl, LogFile>(b.get());
return *a_impl < *b_impl;
});
return status;
}

Loading…
Cancel
Save