diff options
author | Victor Costan <costan@google.com> | 2019-05-04 17:40:21 -0700 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2019-05-04 17:42:20 -0700 |
commit | 24424a1ef2c284f4ec30544a3458023362cbeacd (patch) | |
tree | 9af6fa8b9f885a3a3f8b5c011e882cab4c25dd4c /util | |
parent | 9a56c49ed415df1b72ba1c84c8e7ed00de497f68 (diff) | |
download | leveldb-24424a1ef2c284f4ec30544a3458023362cbeacd.tar.gz |
Style cleanup.
1) Convert iterator-based for loops to C++11 foreach loops.
2) Convert "void operator=" to "T& operator=".
3) Switch from copy operators from private to public deleted.
4) Switch from empty ctors / dtors to "= default" where appropriate.
PiperOrigin-RevId: 246679195
Diffstat (limited to 'util')
-rw-r--r-- | util/comparator.cc | 18 | ||||
-rw-r--r-- | util/env.cc | 12 |
2 files changed, 16 insertions, 14 deletions
diff --git a/util/comparator.cc b/util/comparator.cc index 26d1eb3..c5766e9 100644 --- a/util/comparator.cc +++ b/util/comparator.cc @@ -2,32 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. +#include "leveldb/comparator.h" + #include <algorithm> #include <cstdint> #include <string> +#include <type_traits> -#include "leveldb/comparator.h" #include "leveldb/slice.h" #include "util/logging.h" #include "util/no_destructor.h" namespace leveldb { -Comparator::~Comparator() {} +Comparator::~Comparator() = default; namespace { class BytewiseComparatorImpl : public Comparator { public: - BytewiseComparatorImpl() {} + BytewiseComparatorImpl() = default; - virtual const char* Name() const { return "leveldb.BytewiseComparator"; } + const char* Name() const override { return "leveldb.BytewiseComparator"; } - virtual int Compare(const Slice& a, const Slice& b) const { + int Compare(const Slice& a, const Slice& b) const override { return a.compare(b); } - virtual void FindShortestSeparator(std::string* start, - const Slice& limit) const { + void FindShortestSeparator(std::string* start, + const Slice& limit) const override { // Find length of common prefix size_t min_length = std::min(start->size(), limit.size()); size_t diff_index = 0; @@ -49,7 +51,7 @@ class BytewiseComparatorImpl : public Comparator { } } - virtual void FindShortSuccessor(std::string* key) const { + void FindShortSuccessor(std::string* key) const override { // Find first character that can be incremented size_t n = key->size(); for (size_t i = 0; i < n; i++) { diff --git a/util/env.cc b/util/env.cc index 6cd5f2e..d2f0aef 100644 --- a/util/env.cc +++ b/util/env.cc @@ -6,21 +6,21 @@ namespace leveldb { -Env::~Env() {} +Env::~Env() = default; Status Env::NewAppendableFile(const std::string& fname, WritableFile** result) { return Status::NotSupported("NewAppendableFile", fname); } -SequentialFile::~SequentialFile() {} +SequentialFile::~SequentialFile() = default; -RandomAccessFile::~RandomAccessFile() {} +RandomAccessFile::~RandomAccessFile() = default; -WritableFile::~WritableFile() {} +WritableFile::~WritableFile() = default; -Logger::~Logger() {} +Logger::~Logger() = default; -FileLock::~FileLock() {} +FileLock::~FileLock() = default; void Log(Logger* info_log, const char* format, ...) { if (info_log != nullptr) { |