Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kernald committed Jun 2, 2021
1 parent 6c96de0 commit 467dd6d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/google/protobuf/util/field_mask_util.cc
Expand Up @@ -62,23 +62,23 @@ bool FieldMaskUtil::SnakeCaseToCamelCase(StringPiece input,
std::string* output) {
output->clear();
bool after_underscore = false;
for (unsigned int i = 0; i < input.size(); ++i) {
if (input[i] >= 'A' && input[i] <= 'Z') {
for (const char& input_char : input) {
if (input_char >= 'A' && input_char <= 'Z') {
// The field name must not contain uppercase letters.
return false;
}
if (after_underscore) {
if (input[i] >= 'a' && input[i] <= 'z') {
output->push_back(input[i] + 'A' - 'a');
if (input_char >= 'a' && input_char <= 'z') {
output->push_back(input_char + 'A' - 'a');
after_underscore = false;
} else {
// The character after a "_" must be a lowercase letter.
return false;
}
} else if (input[i] == '_') {
} else if (input_char == '_') {
after_underscore = true;
} else {
output->push_back(input[i]);
output->push_back(input_char);
}
}
if (after_underscore) {
Expand Down Expand Up @@ -331,14 +331,13 @@ void FieldMaskTree::AddPath(const std::string& path) {
}
bool new_branch = false;
Node* node = &root_;
for (const std::string& part : parts) {
for (const std::string& node_name : parts) {
if (!new_branch && node != &root_ && node->children.empty()) {
// Path matches an existing leaf node. This means the path is already
// covered by this tree (for example, adding "foo.bar.baz" to a tree
// which already contains "foo.bar").
return;
}
const std::string& node_name = part;
Node*& child = node->children[node_name];
if (child == NULL) {
new_branch = true;
Expand Down

0 comments on commit 467dd6d

Please sign in to comment.