Skip to content

Commit 43c41d1

Browse files
committed
snake_case
1 parent 721bd40 commit 43c41d1

File tree

2 files changed

+62
-62
lines changed

2 files changed

+62
-62
lines changed

Firestore/core/src/firebase/firestore/local/leveldb_key.cc

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ void WriteComponentLabel(std::string *dest, ComponentLabel label) {
122122
* unread byte, and label will be set to the decoded label value.
123123
*/
124124
bool ReadComponentLabel(absl::string_view *contents, ComponentLabel *label) {
125-
int64_t rawResult = 0;
125+
int64_t raw_result = 0;
126126
absl::string_view tmp(contents->data(), contents->size());
127-
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &rawResult)) {
128-
if (rawResult >= ComponentLabel::Terminator &&
129-
rawResult <= ComponentLabel::Unknown) {
130-
*label = static_cast<ComponentLabel>(rawResult);
127+
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &raw_result)) {
128+
if (raw_result >= ComponentLabel::Terminator &&
129+
raw_result <= ComponentLabel::Unknown) {
130+
*label = static_cast<ComponentLabel>(raw_result);
131131
*contents = absl::string_view(tmp.data(), tmp.size());
132132
return true;
133133
}
@@ -139,18 +139,18 @@ bool ReadComponentLabel(absl::string_view *contents, ComponentLabel *label) {
139139
* Reads a component label from the given key contents.
140140
*
141141
* If the read is unsuccessful or if the read was successful but the label that
142-
* was read did not match the expectedLabel returns false and changes none of
142+
* was read did not match the expected_label returns false and changes none of
143143
* its arguments.
144144
*
145145
* If the read is successful, returns true and contents will be updated to the
146146
* next unread byte.
147147
*/
148148
bool ReadComponentLabelMatching(absl::string_view *contents,
149-
ComponentLabel expectedLabel) {
150-
int64_t rawResult = 0;
149+
ComponentLabel expected_label) {
150+
int64_t raw_result = 0;
151151
absl::string_view tmp = *contents;
152-
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &rawResult)) {
153-
if (rawResult == expectedLabel) {
152+
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &raw_result)) {
153+
if (raw_result == expected_label) {
154154
*contents = tmp;
155155
return true;
156156
}
@@ -169,12 +169,12 @@ bool ReadComponentLabelMatching(absl::string_view *contents,
169169
* unread byte, and result will be set to the decoded integer value.
170170
*/
171171
bool ReadInt32(absl::string_view *contents, int32_t *result) {
172-
int64_t rawResult = 0;
172+
int64_t raw_result = 0;
173173
absl::string_view tmp(contents->data(), contents->size());
174-
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &rawResult)) {
175-
if (rawResult >= INT32_MIN && rawResult <= INT32_MAX) {
174+
if (OrderedCode::ReadSignedNumIncreasing(&tmp, &raw_result)) {
175+
if (raw_result >= INT32_MIN && raw_result <= INT32_MAX) {
176176
*contents = absl::string_view(tmp.data(), tmp.size());
177-
*result = static_cast<int32_t>(rawResult);
177+
*result = static_cast<int32_t>(raw_result);
178178
return true;
179179
}
180180
}
@@ -191,7 +191,7 @@ void WriteLabeledInt32(std::string *dest, ComponentLabel label, int32_t value) {
191191

192192
/**
193193
* Reads a component label and signed number from the given key contents and
194-
* verifies that the label matches the expectedLabel and the value fits in a
194+
* verifies that the label matches the expected_label and the value fits in a
195195
* 32-bit integer.
196196
*
197197
* If the read is unsuccessful, the label didn't match, or the number that was
@@ -202,13 +202,13 @@ void WriteLabeledInt32(std::string *dest, ComponentLabel label, int32_t value) {
202202
* unread byte, and value will be set to the decoded integer value.
203203
*/
204204
bool ReadLabeledInt32(absl::string_view *contents,
205-
ComponentLabel expectedLabel,
205+
ComponentLabel expected_label,
206206
int32_t *value) {
207207
absl::string_view tmp(contents->data(), contents->size());
208-
if (ReadComponentLabelMatching(&tmp, expectedLabel)) {
209-
absl::string_view tmpSlice = absl::string_view(tmp.data(), tmp.size());
210-
if (ReadInt32(&tmpSlice, value)) {
211-
*contents = tmpSlice;
208+
if (ReadComponentLabelMatching(&tmp, expected_label)) {
209+
absl::string_view tmp_slice = absl::string_view(tmp.data(), tmp.size());
210+
if (ReadInt32(&tmp_slice, value)) {
211+
*contents = tmp_slice;
212212
return true;
213213
}
214214
}
@@ -227,7 +227,7 @@ void WriteLabeledString(std::string *dest,
227227

228228
/**
229229
* Reads a component label and a string from the given key contents and verifies
230-
* that the label matches the expectedLabel.
230+
* that the label matches the expected_label.
231231
*
232232
* If the read is unsuccessful or the label didn't match, returns false, and
233233
* changes none of its arguments.
@@ -236,10 +236,10 @@ void WriteLabeledString(std::string *dest,
236236
* unread byte, and value will be set to the decoded string value.
237237
*/
238238
bool ReadLabeledString(absl::string_view *contents,
239-
ComponentLabel expectedLabel,
239+
ComponentLabel expected_label,
240240
std::string *value) {
241241
absl::string_view tmp(contents->data(), contents->size());
242-
if (ReadComponentLabelMatching(&tmp, expectedLabel)) {
242+
if (ReadComponentLabelMatching(&tmp, expected_label)) {
243243
if (OrderedCode::ReadString(&tmp, value)) {
244244
*contents = absl::string_view(tmp.data(), tmp.size());
245245
return true;
@@ -251,8 +251,8 @@ bool ReadLabeledString(absl::string_view *contents,
251251

252252
/**
253253
* Reads a component label and a string from the given key contents and verifies
254-
* that the label matches the expectedLabel and the string matches the
255-
* expectedValue.
254+
* that the label matches the expected_label and the string matches the
255+
* expected_value.
256256
*
257257
* If the read is unsuccessful, the label or didn't match, or the string value
258258
* didn't match, returns false, and changes none of its arguments.
@@ -261,12 +261,12 @@ bool ReadLabeledString(absl::string_view *contents,
261261
* unread byte.
262262
*/
263263
bool ReadLabeledStringMatching(absl::string_view *contents,
264-
ComponentLabel expectedLabel,
265-
const char *expectedValue) {
264+
ComponentLabel expected_label,
265+
const char *expected_value) {
266266
std::string value;
267267
absl::string_view tmp = *contents;
268-
if (ReadLabeledString(&tmp, expectedLabel, &value)) {
269-
if (value == expectedValue) {
268+
if (ReadLabeledString(&tmp, expected_label, &value)) {
269+
if (value == expected_value) {
270270
*contents = tmp;
271271
return true;
272272
}
@@ -299,33 +299,33 @@ void WriteResourcePath(std::string *dest, const ResourcePath &path) {
299299
* unread byte, and value will be set to the decoded document key.
300300
*/
301301
bool ReadDocumentKey(absl::string_view *contents, DocumentKey *result) {
302-
absl::string_view completeSegments = *contents;
302+
absl::string_view complete_segments = *contents;
303303

304304
std::string segment;
305305
std::vector<std::string> path_segments{};
306306
for (;;) {
307307
// Advance a temporary slice to avoid advancing contents into the next key
308308
// component which may not be a path segment.
309-
absl::string_view readPosition(completeSegments.data(),
310-
completeSegments.size());
311-
if (!ReadComponentLabelMatching(&readPosition,
309+
absl::string_view read_position(complete_segments.data(),
310+
complete_segments.size());
311+
if (!ReadComponentLabelMatching(&read_position,
312312
ComponentLabel::PathSegment)) {
313313
break;
314314
}
315-
if (!OrderedCode::ReadString(&readPosition, &segment)) {
315+
if (!OrderedCode::ReadString(&read_position, &segment)) {
316316
return false;
317317
}
318318

319319
path_segments.push_back(std::move(segment));
320320
segment.clear();
321321

322-
completeSegments =
323-
absl::string_view(readPosition.data(), readPosition.size());
322+
complete_segments =
323+
absl::string_view(read_position.data(), read_position.size());
324324
}
325325

326326
ResourcePath path{std::move(path_segments)};
327327
if (path.size() > 0 && DocumentKey::IsDocumentKey(path)) {
328-
*contents = completeSegments;
328+
*contents = complete_segments;
329329
*result = DocumentKey(std::move(path));
330330
return true;
331331
}
@@ -346,14 +346,14 @@ inline bool ReadTerminator(absl::string_view *contents) {
346346
return result;
347347
}
348348

349-
inline void WriteTableName(std::string *dest, const char *tableName) {
350-
WriteLabeledString(dest, ComponentLabel::TableName, tableName);
349+
inline void WriteTableName(std::string *dest, const char *table_name) {
350+
WriteLabeledString(dest, ComponentLabel::TableName, table_name);
351351
}
352352

353353
inline bool ReadTableNameMatching(absl::string_view *contents,
354-
const char *expectedTableName) {
354+
const char *expected_table_name) {
355355
return ReadLabeledStringMatching(contents, ComponentLabel::TableName,
356-
expectedTableName);
356+
expected_table_name);
357357
}
358358

359359
inline void WriteBatchID(std::string *dest, model::BatchId batch_id) {
@@ -405,7 +405,7 @@ std::string InvalidKey(const absl::string_view key) {
405405

406406
std::string Describe(const absl::string_view key) {
407407
absl::string_view contents = key;
408-
bool isTerminated = false;
408+
bool is_terminated = false;
409409

410410
std::string description;
411411
absl::StrAppend(&description, "[");
@@ -418,7 +418,7 @@ std::string Describe(const absl::string_view key) {
418418
}
419419

420420
if (label == ComponentLabel::Terminator) {
421-
isTerminated = true;
421+
is_terminated = true;
422422
contents = tmp;
423423
break;
424424
}
@@ -428,12 +428,12 @@ std::string Describe(const absl::string_view key) {
428428
tmp = contents;
429429

430430
if (label == ComponentLabel::PathSegment) {
431-
DocumentKey documentKey;
432-
if (!ReadDocumentKey(&tmp, &documentKey)) {
431+
DocumentKey document_key;
432+
if (!ReadDocumentKey(&tmp, &document_key)) {
433433
break;
434434
}
435435
absl::StrAppend(&description,
436-
" key=", documentKey.path().CanonicalString());
436+
" key=", document_key.path().CanonicalString());
437437

438438
} else if (label == ComponentLabel::TableName) {
439439
std::string table;
@@ -481,7 +481,7 @@ std::string Describe(const absl::string_view key) {
481481
if (contents.size() > 0) {
482482
absl::StrAppend(&description, " invalid key=<", InvalidKey(key), ">");
483483

484-
} else if (!isTerminated) {
484+
} else if (!is_terminated) {
485485
absl::StrAppend(&description, " incomplete key");
486486
}
487487

@@ -674,11 +674,11 @@ std::string LevelDbTargetDocumentKey::KeyPrefix(model::TargetId target_id) {
674674
}
675675

676676
std::string LevelDbTargetDocumentKey::Key(model::TargetId target_id,
677-
const DocumentKey &documentKey) {
677+
const DocumentKey &document_key) {
678678
std::string result;
679679
WriteTableName(&result, kTargetDocumentsTable);
680680
WriteTargetID(&result, target_id);
681-
WriteResourcePath(&result, documentKey.path());
681+
WriteResourcePath(&result, document_key.path());
682682
WriteTerminator(&result);
683683
return result;
684684
}
@@ -707,11 +707,11 @@ std::string LevelDbDocumentTargetKey::KeyPrefix(
707707
return result;
708708
}
709709

710-
std::string LevelDbDocumentTargetKey::Key(const DocumentKey &documentKey,
710+
std::string LevelDbDocumentTargetKey::Key(const DocumentKey &document_key,
711711
model::TargetId target_id) {
712712
std::string result;
713713
WriteTableName(&result, kDocumentTargetsTable);
714-
WriteResourcePath(&result, documentKey.path());
714+
WriteResourcePath(&result, document_key.path());
715715
WriteTargetID(&result, target_id);
716716
WriteTerminator(&result);
717717
return result;

Firestore/core/test/firebase/firestore/local/leveldb_key_test.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,27 @@ TEST(LevelDbMutationKeyTest, Description) {
122122
}
123123

124124
TEST(LevelDbDocumentMutationKeyTest, Prefixing) {
125-
auto tableKey = LevelDbDocumentMutationKey::KeyPrefix();
126-
auto emptyUserKey = LevelDbDocumentMutationKey::KeyPrefix("");
127-
auto fooUserKey = LevelDbDocumentMutationKey::KeyPrefix("foo");
125+
auto table_key = LevelDbDocumentMutationKey::KeyPrefix();
126+
auto empty_user_key = LevelDbDocumentMutationKey::KeyPrefix("");
127+
auto foo_user_key = LevelDbDocumentMutationKey::KeyPrefix("foo");
128128

129-
DocumentKey documentKey = testutil::Key("foo/bar");
130-
auto foo2Key = LevelDbDocumentMutationKey::Key("foo", documentKey, 2);
129+
DocumentKey document_key = testutil::Key("foo/bar");
130+
auto foo2_key = LevelDbDocumentMutationKey::Key("foo", document_key, 2);
131131

132-
ASSERT_TRUE(util::StartsWith(emptyUserKey, tableKey));
132+
ASSERT_TRUE(util::StartsWith(empty_user_key, table_key));
133133

134134
// While we want a key with whole segments in common be considered a prefix
135135
// it's vital that partial segments in common not be prefixes.
136-
ASSERT_TRUE(util::StartsWith(fooUserKey, tableKey));
136+
ASSERT_TRUE(util::StartsWith(foo_user_key, table_key));
137137

138138
// Here even though "" is a prefix of "foo" that prefix is within a segment so
139139
// keys derived from those segments cannot be prefixes of each other.
140-
ASSERT_FALSE(util::StartsWith(fooUserKey, emptyUserKey));
141-
ASSERT_FALSE(util::StartsWith(emptyUserKey, fooUserKey));
140+
ASSERT_FALSE(util::StartsWith(foo_user_key, empty_user_key));
141+
ASSERT_FALSE(util::StartsWith(empty_user_key, foo_user_key));
142142

143143
// However whole segments in common are prefixes.
144-
ASSERT_TRUE(util::StartsWith(foo2Key, tableKey));
145-
ASSERT_TRUE(util::StartsWith(foo2Key, fooUserKey));
144+
ASSERT_TRUE(util::StartsWith(foo2_key, table_key));
145+
ASSERT_TRUE(util::StartsWith(foo2_key, foo_user_key));
146146
}
147147

148148
TEST(LevelDbDocumentMutationKeyTest, EncodeDecodeCycle) {

0 commit comments

Comments
 (0)