diff options
author | Chris Mumford <cmumford@google.com> | 2019-05-02 11:01:00 -0700 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2019-05-02 19:04:50 -0700 |
commit | 297e66afc1dda3f3d7a7cc2022030164c302cb7a (patch) | |
tree | c7266d464e3b361a8f580ebe1e67c128e7e2a712 /util/bloom.cc | |
parent | 3724030179716fd8d95cf79339884c49afade8f9 (diff) | |
download | leveldb-297e66afc1dda3f3d7a7cc2022030164c302cb7a.tar.gz |
Format all files IAW the Google C++ Style Guide.
Use clang-format to correct formatting to be in agreement with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). Doing this simplifies the process of accepting changes. Also fixed a few warnings flagged by clang-tidy.
PiperOrigin-RevId: 246350737
Diffstat (limited to 'util/bloom.cc')
-rw-r--r-- | util/bloom.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/util/bloom.cc b/util/bloom.cc index bf3e4ca..097ce7a 100644 --- a/util/bloom.cc +++ b/util/bloom.cc @@ -20,17 +20,14 @@ class BloomFilterPolicy : public FilterPolicy { size_t k_; public: - explicit BloomFilterPolicy(int bits_per_key) - : bits_per_key_(bits_per_key) { + explicit BloomFilterPolicy(int bits_per_key) : bits_per_key_(bits_per_key) { // We intentionally round down to reduce probing cost a little bit k_ = static_cast<size_t>(bits_per_key * 0.69); // 0.69 =~ ln(2) if (k_ < 1) k_ = 1; if (k_ > 30) k_ = 30; } - virtual const char* Name() const { - return "leveldb.BuiltinBloomFilter2"; - } + virtual const char* Name() const { return "leveldb.BuiltinBloomFilter2"; } virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { // Compute bloom filter size (in both bits and bytes) @@ -54,7 +51,7 @@ class BloomFilterPolicy : public FilterPolicy { const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits for (size_t j = 0; j < k_; j++) { const uint32_t bitpos = h % bits; - array[bitpos/8] |= (1 << (bitpos % 8)); + array[bitpos / 8] |= (1 << (bitpos % 8)); h += delta; } } @@ -69,7 +66,7 @@ class BloomFilterPolicy : public FilterPolicy { // Use the encoded k so that we can read filters generated by // bloom filters created using different parameters. - const size_t k = array[len-1]; + const size_t k = array[len - 1]; if (k > 30) { // Reserved for potentially new encodings for short bloom filters. // Consider it a match. @@ -80,13 +77,13 @@ class BloomFilterPolicy : public FilterPolicy { const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits for (size_t j = 0; j < k; j++) { const uint32_t bitpos = h % bits; - if ((array[bitpos/8] & (1 << (bitpos % 8))) == 0) return false; + if ((array[bitpos / 8] & (1 << (bitpos % 8))) == 0) return false; h += delta; } return true; } }; -} +} // namespace const FilterPolicy* NewBloomFilterPolicy(int bits_per_key) { return new BloomFilterPolicy(bits_per_key); |