Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1270)

Unified Diff: third_party/protobuf/src/google/protobuf/util/internal/utility.cc

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/util/internal/utility.cc
diff --git a/third_party/protobuf/src/google/protobuf/util/internal/utility.cc b/third_party/protobuf/src/google/protobuf/util/internal/utility.cc
index 05759e85ab62abb0d60ae2de4d3455282b3c171f..ee7a51fc41b6db81b4ee9b58cfaa11d7a023791e 100644
--- a/third_party/protobuf/src/google/protobuf/util/internal/utility.cc
+++ b/third_party/protobuf/src/google/protobuf/util/internal/utility.cc
@@ -30,8 +30,6 @@
#include <google/protobuf/util/internal/utility.h>
-#include <algorithm>
-
#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
@@ -54,7 +52,7 @@ const StringPiece SkipWhiteSpace(StringPiece str) {
for (i = 0; i < str.size() && isspace(str[i]); ++i) {
}
GOOGLE_DCHECK(i == str.size() || !isspace(str[i]));
- return str.substr(i);
+ return StringPiece(str, i);
}
} // namespace
@@ -130,12 +128,8 @@ string GetStringFromAny(const google::protobuf::Any& any) {
}
const StringPiece GetTypeWithoutUrl(StringPiece type_url) {
- if (type_url.size() > kTypeUrlSize && type_url[kTypeUrlSize] == '/') {
- return type_url.substr(kTypeUrlSize + 1);
- } else {
- size_t idx = type_url.rfind('/');
- return type_url.substr(idx + 1);
- }
+ size_t idx = type_url.rfind('/');
+ return type_url.substr(idx + 1);
}
const string GetFullTypeWithUrl(StringPiece simple_type) {
@@ -180,19 +174,6 @@ const google::protobuf::Field* FindJsonFieldInTypeOrNull(
return NULL;
}
-const google::protobuf::Field* FindFieldInTypeByNumberOrNull(
- const google::protobuf::Type* type, int32 number) {
- if (type != NULL) {
- for (int i = 0; i < type->fields_size(); ++i) {
- const google::protobuf::Field& field = type->fields(i);
- if (field.number() == number) {
- return &field;
- }
- }
- }
- return NULL;
-}
-
const google::protobuf::EnumValue* FindEnumValueByNameOrNull(
const google::protobuf::Enum* enum_type, StringPiece enum_name) {
if (enum_type != NULL) {
@@ -219,32 +200,6 @@ const google::protobuf::EnumValue* FindEnumValueByNumberOrNull(
return NULL;
}
-const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull(
- const google::protobuf::Enum* enum_type, StringPiece enum_name) {
- if (enum_type != NULL) {
- for (int i = 0; i < enum_type->enumvalue_size(); ++i) {
- const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);
- string enum_name_without_underscore = enum_value.name();
-
- // Remove underscore from the name.
- enum_name_without_underscore.erase(
- std::remove(enum_name_without_underscore.begin(),
- enum_name_without_underscore.end(), '_'),
- enum_name_without_underscore.end());
- // Make the name uppercase.
- for (string::iterator it = enum_name_without_underscore.begin();
- it != enum_name_without_underscore.end(); ++it) {
- *it = ascii_toupper(*it);
- }
-
- if (enum_name_without_underscore == enum_name) {
- return &enum_value;
- }
- }
- }
- return NULL;
-}
-
string ToCamelCase(const StringPiece input) {
bool capitalize_next = false;
bool was_cap = true;
@@ -324,7 +279,7 @@ string ToSnakeCase(StringPiece input) {
return result;
}
-std::set<string>* well_known_types_ = NULL;
+set<string>* well_known_types_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(well_known_types_init_);
const char* well_known_types_name_array_[] = {
"google.protobuf.Timestamp", "google.protobuf.Duration",
@@ -337,7 +292,7 @@ const char* well_known_types_name_array_[] = {
void DeleteWellKnownTypes() { delete well_known_types_; }
void InitWellKnownTypes() {
- well_known_types_ = new std::set<string>;
+ well_known_types_ = new set<string>;
for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
well_known_types_->insert(well_known_types_name_array_[i]);
}
@@ -356,23 +311,15 @@ bool IsValidBoolString(const string& bool_string) {
bool IsMap(const google::protobuf::Field& field,
const google::protobuf::Type& type) {
- return (
- field.cardinality() ==
- google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&
- (GetBoolOptionOrDefault(
- type.options(), "google.protobuf.MessageOptions.map_entry", false) ||
- GetBoolOptionOrDefault(type.options(), "proto2.MessageOptions.map_entry",
- false)));
+ return (field.cardinality() ==
+ google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&
+ GetBoolOptionOrDefault(type.options(),
+ "google.protobuf.MessageOptions.map_entry", false));
}
bool IsMessageSetWireFormat(const google::protobuf::Type& type) {
- return (
- GetBoolOptionOrDefault(
- type.options(),
- "google.protobuf.MessageOptions.message_set_wire_format", false) ||
- GetBoolOptionOrDefault(type.options(),
- "proto2.MessageOptions.message_set_wire_format",
- false));
+ return GetBoolOptionOrDefault(
+ type.options(), "google.protobuf.MessageOptions.message_set_wire_format", false);
}
string DoubleAsString(double value) {
@@ -412,4 +359,3 @@ bool SafeStrToFloat(StringPiece str, float* value) {
} // namespace util
} // namespace protobuf
} // namespace google
-

Powered by Google App Engine
This is Rietveld 408576698