Skip to content

Commit 297e66a

Browse files
cmumfordpwnall
authored andcommitted
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
1 parent 3724030 commit 297e66a

File tree

125 files changed

+1970
-2329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1970
-2329
lines changed

.clang-format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Run manually to reformat a file:
2+
# clang-format -i --style=file <file>
3+
# find . -iname '*.cc' -o -iname '*.h' -o -iname '*.h.in' | xargs clang-format -i --style=file
4+
BasedOnStyle: Google
5+
DerivePointerAlignment: false
6+
7+
# Public headers are in a different location in the internal Google repository.
8+
# Order them so that when imported to the authoritative repository they will be
9+
# in correct alphabetical order.
10+
IncludeCategories:
11+
- Regex: '^(<|"(db|helpers)/)'
12+
Priority: 1
13+
- Regex: '^"(leveldb)/'
14+
Priority: 2
15+
- Regex: '^(<|"(issues|port|table|third_party|util)/)'
16+
Priority: 3
17+
- Regex: '.*'
18+
Priority: 4

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ Contribution requirements:
8686
3. **Tests**: All changes must be accompanied by a new (or changed) test, or
8787
a sufficient explanation as to why a new (or changed) test is not required.
8888

89+
4. **Consistent Style**: This project conforms to the
90+
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
91+
To ensure your changes are properly formatted please run:
92+
93+
```
94+
clang-format -i --style=file <file>
95+
```
96+
8997
## Submitting a Pull Request
9098

9199
Before any pull request will be accepted the author must first sign a

db/autocompact_test.cc

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file. See the AUTHORS file for names of contributors.
44

5-
#include "leveldb/db.h"
65
#include "db/db_impl.h"
76
#include "leveldb/cache.h"
7+
#include "leveldb/db.h"
88
#include "util/testharness.h"
99
#include "util/testutil.h"
1010

@@ -81,17 +81,16 @@ void AutoCompactTest::DoReads(int n) {
8181
ASSERT_LT(read, 100) << "Taking too long to compact";
8282
Iterator* iter = db_->NewIterator(ReadOptions());
8383
for (iter->SeekToFirst();
84-
iter->Valid() && iter->key().ToString() < limit_key;
85-
iter->Next()) {
84+
iter->Valid() && iter->key().ToString() < limit_key; iter->Next()) {
8685
// Drop data
8786
}
8887
delete iter;
8988
// Wait a little bit to allow any triggered compactions to complete.
9089
Env::Default()->SleepForMicroseconds(1000000);
9190
uint64_t size = Size(Key(0), Key(n));
92-
fprintf(stderr, "iter %3d => %7.3f MB [other %7.3f MB]\n",
93-
read+1, size/1048576.0, Size(Key(n), Key(kCount))/1048576.0);
94-
if (size <= initial_size/10) {
91+
fprintf(stderr, "iter %3d => %7.3f MB [other %7.3f MB]\n", read + 1,
92+
size / 1048576.0, Size(Key(n), Key(kCount)) / 1048576.0);
93+
if (size <= initial_size / 10) {
9594
break;
9695
}
9796
}
@@ -100,19 +99,13 @@ void AutoCompactTest::DoReads(int n) {
10099
// is pretty much unchanged.
101100
const int64_t final_other_size = Size(Key(n), Key(kCount));
102101
ASSERT_LE(final_other_size, initial_other_size + 1048576);
103-
ASSERT_GE(final_other_size, initial_other_size/5 - 1048576);
102+
ASSERT_GE(final_other_size, initial_other_size / 5 - 1048576);
104103
}
105104

106-
TEST(AutoCompactTest, ReadAll) {
107-
DoReads(kCount);
108-
}
105+
TEST(AutoCompactTest, ReadAll) { DoReads(kCount); }
109106

110-
TEST(AutoCompactTest, ReadHalf) {
111-
DoReads(kCount/2);
112-
}
107+
TEST(AutoCompactTest, ReadHalf) { DoReads(kCount / 2); }
113108

114109
} // namespace leveldb
115110

116-
int main(int argc, char** argv) {
117-
return leveldb::test::RunAllTests();
118-
}
111+
int main(int argc, char** argv) { return leveldb::test::RunAllTests(); }

db/builder.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include "db/builder.h"
66

7-
#include "db/filename.h"
87
#include "db/dbformat.h"
8+
#include "db/filename.h"
99
#include "db/table_cache.h"
1010
#include "db/version_edit.h"
1111
#include "leveldb/db.h"
@@ -14,12 +14,8 @@
1414

1515
namespace leveldb {
1616

17-
Status BuildTable(const std::string& dbname,
18-
Env* env,
19-
const Options& options,
20-
TableCache* table_cache,
21-
Iterator* iter,
22-
FileMetaData* meta) {
17+
Status BuildTable(const std::string& dbname, Env* env, const Options& options,
18+
TableCache* table_cache, Iterator* iter, FileMetaData* meta) {
2319
Status s;
2420
meta->file_size = 0;
2521
iter->SeekToFirst();
@@ -60,8 +56,7 @@ Status BuildTable(const std::string& dbname,
6056

6157
if (s.ok()) {
6258
// Verify that the table is usable
63-
Iterator* it = table_cache->NewIterator(ReadOptions(),
64-
meta->number,
59+
Iterator* it = table_cache->NewIterator(ReadOptions(), meta->number,
6560
meta->file_size);
6661
s = it->status();
6762
delete it;

db/builder.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ class VersionEdit;
2222
// *meta will be filled with metadata about the generated table.
2323
// If no data is present in *iter, meta->file_size will be set to
2424
// zero, and no Table file will be produced.
25-
Status BuildTable(const std::string& dbname,
26-
Env* env,
27-
const Options& options,
28-
TableCache* table_cache,
29-
Iterator* iter,
30-
FileMetaData* meta);
25+
Status BuildTable(const std::string& dbname, Env* env, const Options& options,
26+
TableCache* table_cache, Iterator* iter, FileMetaData* meta);
3127

3228
} // namespace leveldb
3329

0 commit comments

Comments
 (0)