diff --git a/BUILD b/BUILD
index 1664621e95..e9e108377a 100644
--- a/BUILD
+++ b/BUILD
@@ -93,7 +93,6 @@ cc_library(
srcs = [
# AUTOGEN(protobuf_lite_srcs)
"src/google/protobuf/arena.cc",
- "src/google/protobuf/arenastring.cc",
"src/google/protobuf/extension_set.cc",
"src/google/protobuf/generated_message_table_driven_lite.cc",
"src/google/protobuf/generated_message_util.cc",
diff --git a/conformance/conformance.proto b/conformance/conformance.proto
index b61f3569d4..271476dc5e 100644
--- a/conformance/conformance.proto
+++ b/conformance/conformance.proto
@@ -71,7 +71,7 @@ enum TestCategory {
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
// Test jspb wire format. Google internal only. Opensource testees just skip it.
JSPB_TEST = 4;
- // Test text format. For cpp, java and python, testees can already deal with
+ // Test text format. For cpp, java and python, testees can already deal with
// this type. Testees of other languages can simply skip it.
TEXT_FORMAT_TEST = 5;
}
@@ -169,3 +169,4 @@ message JspbEncodingConfig {
// Encode the value field of Any as jspb array if ture, otherwise binary.
bool use_jspb_array_any_format = 1;
}
+
diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
index 3b2bb0311a..73a140d3d1 100644
--- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
@@ -93,7 +93,7 @@ namespace Conformance {
///
[pbr::OriginalName("JSPB_TEST")] JspbTest = 4,
///
- /// Test text format. For cpp, java and python, testees can already deal with
+ /// Test text format. For cpp, java and python, testees can already deal with
/// this type. Testees of other languages can simply skip it.
///
[pbr::OriginalName("TEXT_FORMAT_TEST")] TextFormatTest = 5,
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc
index 4e994a8075..0b68e1d445 100644
--- a/src/google/protobuf/any.pb.cc
+++ b/src/google/protobuf/any.pb.cc
@@ -210,16 +210,13 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Any.type_url");
- auto str = msg->mutable_type_url();
+ object = msg->mutable_type_url();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -228,16 +225,13 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- auto str = msg->mutable_value();
+ object = msg->mutable_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParser;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheck(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -256,6 +250,10 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc
index 63695f78a0..2a6ca2bf82 100644
--- a/src/google/protobuf/api.pb.cc
+++ b/src/google/protobuf/api.pb.cc
@@ -316,16 +316,13 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Api.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -338,11 +335,9 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
parser_till_end = ::google::protobuf::Method::_InternalParse;
object = msg->add_methods();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -356,11 +351,9 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
@@ -371,16 +364,13 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Api.version");
- auto str = msg->mutable_version();
+ object = msg->mutable_version();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -392,11 +382,9 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.protobuf.Mixin mixins = 6;
@@ -408,11 +396,9 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
parser_till_end = ::google::protobuf::Mixin::_InternalParse;
object = msg->add_mixins();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
@@ -420,11 +406,9 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
// .google.protobuf.Syntax syntax = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_syntax(static_cast<::google::protobuf::Syntax>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
- msg->set_syntax(value);
break;
}
default: {
@@ -442,6 +426,10 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -987,16 +975,13 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1006,27 +991,21 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.request_type_url");
- auto str = msg->mutable_request_type_url();
+ object = msg->mutable_request_type_url();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// bool request_streaming = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_request_streaming(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_request_streaming(value);
break;
}
// string response_type_url = 4;
@@ -1035,27 +1014,21 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.response_type_url");
- auto str = msg->mutable_response_type_url();
+ object = msg->mutable_response_type_url();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// bool response_streaming = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_response_streaming(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_response_streaming(value);
break;
}
// repeated .google.protobuf.Option options = 6;
@@ -1067,11 +1040,9 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
@@ -1079,11 +1050,9 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
// .google.protobuf.Syntax syntax = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_syntax(static_cast<::google::protobuf::Syntax>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
- msg->set_syntax(value);
break;
}
default: {
@@ -1101,6 +1070,10 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1616,16 +1589,13 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Mixin.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1635,16 +1605,13 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Mixin.root");
- auto str = msg->mutable_root();
+ object = msg->mutable_root();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1663,6 +1630,10 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc
deleted file mode 100644
index 7f33a0c865..0000000000
--- a/src/google/protobuf/arenastring.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The ArenaString implementation is not included in the open-source release. Do
-// not include this file in the distribution.
-
-#include
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc
index f866eb6e0b..9b25797647 100644
--- a/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc
@@ -40,6 +40,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -95,7 +96,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["name"] = name;
variables_["constant_name"] = FieldConstantName(descriptor_);
variables_["field_type"] =
- SimpleItoa(static_cast(descriptor_->type()));
+ StrCat(static_cast(descriptor_->type()));
variables_["packed"] = descriptor_->options().packed() ? "true" : "false";
string scope =
@@ -103,7 +104,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["scope"] = scope;
string scoped_name = scope + name;
variables_["scoped_name"] = scoped_name;
- variables_["number"] = SimpleItoa(descriptor_->number());
+ variables_["number"] = StrCat(descriptor_->number());
}
ExtensionGenerator::~ExtensionGenerator() {}
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc
index 582da4ae09..fe20d4bb12 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -62,13 +62,13 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
SetCommonVars(options, variables);
(*variables)["ns"] = Namespace(descriptor);
(*variables)["name"] = FieldName(descriptor);
- (*variables)["index"] = SimpleItoa(descriptor->index());
- (*variables)["number"] = SimpleItoa(descriptor->number());
+ (*variables)["index"] = StrCat(descriptor->index());
+ (*variables)["number"] = StrCat(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
(*variables)["field_member"] = FieldName(descriptor) + "_";
- (*variables)["tag_size"] = SimpleItoa(
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
(*variables)["deprecated_attr"] =
DeprecatedAttribute(options, descriptor->options().deprecated());
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 5df9e8004b..e9abeff8aa 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -50,6 +50,7 @@
#include
+
#include
namespace google {
@@ -477,10 +478,9 @@ void FileGenerator::GenerateInternalForwardDeclarations(
auto scc = scc_analyzer->GetSCC(msg);
string repr =
UniqueName(ClassName(scc->GetRepresentative()), msg, options_);
- global_namespace_decls.insert(
- "extern " + dllexport + weak_attr + " ::" + ProtobufNamespace(options) +
- "::internal::SCCInfo<" + SimpleItoa(scc->children.size()) +
- "> scc_info_" + repr);
+ global_namespace_decls.insert(StrCat(
+ "extern ", dllexport, weak_attr, " ::", ProtobufNamespace(options),
+ "::internal::SCCInfo<", scc->children.size(), "> scc_info_", repr));
}
format("\n");
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc
index ba631d303f..e4ec690a03 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -46,6 +46,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -203,8 +204,7 @@ bool CppGenerator::Generate(const FileDescriptor* file,
}
for (int i = 0; i < num_cc_files; i++) {
std::unique_ptr output(
- generator_context->Open(basename + ".out/" +
- SimpleItoa(i) + ".cc"));
+ generator_context->Open(StrCat(basename, ".out/", i, ".cc")));
io::Printer printer(output.get(), '$');
if (i < file_generator.NumMessages()) {
file_generator.GenerateSourceForMessage(i, &printer);
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 8e35a0e0a9..e6cbdf4668 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -41,6 +41,7 @@
#include
#include
#include
+
#include
#include
#include
@@ -420,7 +421,7 @@ string FieldConstantName(const FieldDescriptor* field) {
// This field's camelcase name is not unique. As a hack, add the field
// number to the constant name. This makes the constant rather useless,
// but what can we do?
- result += "_" + SimpleItoa(field->number());
+ result += "_" + StrCat(field->number());
}
return result;
@@ -555,9 +556,9 @@ string Int32ToString(int number) {
if (number == kint32min) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
- return SimpleItoa(number + 1) + " - 1";
+ return StrCat(number + 1, " - 1");
} else {
- return SimpleItoa(number);
+ return StrCat(number);
}
}
@@ -565,14 +566,13 @@ string Int64ToString(const string& macro_prefix, int64 number) {
if (number == kint64min) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
- return macro_prefix + "_LONGLONG(" + SimpleItoa(number + 1) +
- ") - 1";
+ return StrCat(macro_prefix, "_LONGLONG(", number + 1, ") - 1");
}
- return macro_prefix + "_LONGLONG(" + SimpleItoa(number) + ")";
+ return StrCat(macro_prefix, "_LONGLONG(", number, ")");
}
string UInt64ToString(const string& macro_prefix, uint64 number) {
- return macro_prefix + "_ULONGLONG(" + SimpleItoa(number) + ")";
+ return StrCat(macro_prefix, "_ULONGLONG(", number, ")");
}
string DefaultValue(const FieldDescriptor* field) {
@@ -591,7 +591,7 @@ string DefaultValue(const Options& options, const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_INT32:
return Int32ToString(field->default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
- return SimpleItoa(field->default_value_uint32()) + "u";
+ return StrCat(field->default_value_uint32()) + "u";
case FieldDescriptor::CPPTYPE_INT64:
return Int64ToString("PROTOBUF", field->default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64:
@@ -1422,6 +1422,26 @@ class ParseLoopGenerator {
" } // switch\n"
" } // while\n"
" return ptr;\n");
+ if (use_string_) {
+ format_(
+ "string_till_end:\n"
+ " static_cast<$string$*>(object)->clear();\n"
+ // TODO(gerbens) evaluate security
+ " static_cast<$string$*>(object)->reserve(size);\n"
+ " goto len_delim_till_end;\n");
+ }
+ if (use_arena_string_) {
+ format_(
+ "arena_string_till_end:\n"
+ " object = "
+ "static_cast<::$proto_ns$::internal::ArenaStringPtr*>(object)->"
+ "Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), "
+ "msg->GetArenaNoVirtual());\n"
+ " static_cast<$string$*>(object)->clear();\n"
+ // TODO(gerbens) evaluate security
+ " static_cast<$string$*>(object)->reserve(size);\n"
+ " goto len_delim_till_end;\n");
+ }
if (use_length_delimited_) {
format_(
"len_delim_till_end:\n"
@@ -1447,33 +1467,30 @@ class ParseLoopGenerator {
Formatter format_;
bool use_length_delimited_ = false;
bool use_group_ = false;
+ bool use_string_ = false;
+ bool use_arena_string_ = false;
using WireFormat = internal::WireFormat;
using WireFormatLite = internal::WireFormatLite;
void GenerateArenaString(const FieldDescriptor* field, const string& utf8) {
+ use_arena_string_ = true;
+ if (HasFieldPresence(field->file())) {
+ format_("HasBitSetters::set_has_$1$(msg);\n", FieldName(field));
+ }
format_(
"if (size > end - ptr + "
"::$proto_ns$::internal::ParseContext::kSlopBytes) {\n"
- " auto str = msg->mutable_$1$();\n"
- " str->clear();\n"
- // TODO(gerbens) evaluate security
- " str->reserve(size);\n"
- " object = str;\n"
+ " object = &msg->$1$_;\n"
" parser_till_end = ::$proto_ns$::internal::GreedyStringParser$2$;\n"
- " goto len_delim_till_end;\n"
+ " goto arena_string_till_end;\n"
"}\n"
"$GOOGLE_PROTOBUF$_PARSER_ASSERT(::$proto_ns$::internal::StringCheck$2$"
- "(ptr, size, ctx));\n",
- FieldName(field), utf8);
- if (HasFieldPresence(field->file())) {
- format_("HasBitSetters::set_has_$1$(msg);\n", FieldName(field));
- }
- format_(
+ "(ptr, size, ctx));\n"
"::$proto_ns$::internal::CopyIntoArenaString(ptr, size, &msg->$1$_, "
"msg->GetArenaNoVirtual());\n"
"ptr += size;\n",
- FieldName(field));
+ FieldName(field), utf8);
}
void GenerateStrings(const FieldDescriptor* field, bool check_utf8) {
@@ -1510,40 +1527,40 @@ class ParseLoopGenerator {
return;
}
format_(
- "auto str = msg->$1$_$2$();\n"
+ "object = msg->$1$_$2$();\n"
"if (size > end - ptr + "
- "::$proto_ns$::internal::ParseContext::kSlopBytes) {\n"
- " object = str;\n",
+ "::$proto_ns$::internal::ParseContext::kSlopBytes) {\n",
field->is_repeated() && !field->is_packable() ? "add" : "mutable",
FieldName(field));
string name;
+ string label = "len_delim_till_end";
switch (ctype) {
case FieldOptions::STRING:
name = "GreedyStringParser";
- format_(
- " str->clear();\n"
- // TODO(gerbens) evaluate security
- " str->reserve(size);\n");
+ use_string_ = true;
+ label = "string_till_end";
break;
case FieldOptions::CORD:
name = "CordParser";
- format_(" str->Clear();\n");
+ format_(" static_cast<::Cord*>(object)->Clear();\n");
break;
case FieldOptions::STRING_PIECE:
name = "StringPieceParser";
- format_(" str->Clear();\n");
+ format_(
+ " "
+ "static_cast<::$proto_ns$::internal::StringPieceField*>(object)->"
+ "Clear();\n");
break;
}
format_(
" parser_till_end = ::$proto_ns$::internal::$1$$2$;\n"
- " goto len_delim_till_end;\n"
+ " goto $3$;\n"
"}\n"
"$GOOGLE_PROTOBUF$_PARSER_ASSERT(::$proto_ns$::internal::StringCheck$2$"
- "("
- "ptr, size, ctx));\n"
- "::$proto_ns$::internal::Inline$1$(str, ptr, size, ctx);\n"
+ "(ptr, size, ctx));\n"
+ "::$proto_ns$::internal::Inline$1$(object, ptr, size, ctx);\n"
"ptr += size;\n",
- name, utf8);
+ name, utf8, label);
}
void GenerateLengthDelim(const FieldDescriptor* field) {
@@ -1690,11 +1707,9 @@ class ParseLoopGenerator {
}
format_(
"if (size > end - ptr) goto len_delim_till_end;\n"
- "auto newend = ptr + size;\n"
- "bool ok = ctx->ParseExactRange({parser_till_end, object},\n"
- " ptr, newend);\n"
- "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ok);\n"
- "ptr = newend;\n");
+ "ptr += size;\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ctx->ParseExactRange(\n"
+ " {parser_till_end, object}, ptr - size, ptr));\n");
break;
}
default:
@@ -1712,21 +1727,11 @@ class ParseLoopGenerator {
}
switch (wiretype) {
case WireFormatLite::WIRETYPE_VARINT: {
- format_(
- "$uint64$ val;\n"
- "ptr = ::$proto_ns$::io::Parse64(ptr, &val);\n"
- "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n");
string type = PrimitiveTypeName(options_, field->cpp_type());
- if ((field->type() == FieldDescriptor::TYPE_SINT32 ||
- field->type() == FieldDescriptor::TYPE_SINT64) &&
+ string prefix = field->is_repeated() ? "add" : "set";
+ if (field->type() == FieldDescriptor::TYPE_ENUM &&
!IsProto1(field->file(), options_)) {
- int size = field->type() == FieldDescriptor::TYPE_SINT32 ? 32 : 64;
- format_(
- "$1$ value = "
- "::$proto_ns$::internal::WireFormatLite::ZigZagDecode$2$(val);\n",
- type, size);
- } else if (field->type() == FieldDescriptor::TYPE_ENUM &&
- !IsProto1(field->file(), options_)) {
+ format_("$uint64$ val = ::$proto_ns$::internal::ReadVarint(&ptr);\n");
if (!HasPreservingUnknownEnumSemantics(field->file())) {
format_(
"if (!$1$_IsValid(val)) {\n"
@@ -1736,30 +1741,31 @@ class ParseLoopGenerator {
"}\n",
QualifiedClassName(field->enum_type()), field->number());
}
- format_("$1$ value = static_cast<$1$>(val);\n",
- QualifiedClassName(field->enum_type()));
+ format_("msg->$1$_$2$(static_cast<$3$>(val));\n", prefix,
+ FieldName(field), QualifiedClassName(field->enum_type()));
} else {
- format_("$1$ value = val;\n", type);
- }
- if (field->is_repeated()) {
- format_("msg->add_$1$(value);\n", FieldName(field));
- } else {
- format_("msg->set_$1$(value);\n", FieldName(field));
+ string zigzag;
+ if ((field->type() == FieldDescriptor::TYPE_SINT32 ||
+ field->type() == FieldDescriptor::TYPE_SINT64) &&
+ !IsProto1(field->file(), options_)) {
+ int size = field->type() == FieldDescriptor::TYPE_SINT32 ? 32 : 64;
+ zigzag = StrCat("ZigZag", size);
+ }
+ format_(
+ "msg->$1$_$2$(::$proto_ns$::internal::ReadVarint$3$(&ptr));\n",
+ prefix, FieldName(field), zigzag);
}
+ format_("$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n");
break;
}
+ case WireFormatLite::WIRETYPE_FIXED32:
case WireFormatLite::WIRETYPE_FIXED64: {
+ string prefix = field->is_repeated() ? "add" : "set";
string type = PrimitiveTypeName(options_, field->cpp_type());
format_(
- "$1$ val;\n"
- "::std::memcpy(&val, ptr, 8);\n"
- "ptr += 8;\n",
- type);
- if (field->is_repeated()) {
- format_("msg->add_$1$(val);\n", FieldName(field));
- } else {
- format_("msg->set_$1$(val);\n", FieldName(field));
- }
+ "msg->$1$_$2$(::$proto_ns$::io::UnalignedLoad<$3$>(ptr));\n"
+ "ptr += sizeof($3$);\n",
+ prefix, FieldName(field), type);
break;
}
case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {
@@ -1786,20 +1792,6 @@ class ParseLoopGenerator {
GOOGLE_LOG(FATAL) << "Can't have end group field\n";
break;
}
- case WireFormatLite::WIRETYPE_FIXED32: {
- string type = PrimitiveTypeName(options_, field->cpp_type());
- format_(
- "$1$ val;\n"
- "std::memcpy(&val, ptr, 4);\n"
- "ptr += 4;\n",
- type);
- if (field->is_repeated()) {
- format_("msg->add_$1$(val);\n", FieldName(field));
- } else {
- format_("msg->set_$1$(val);\n", FieldName(field));
- }
- break;
- }
} // switch (wire_type)
if (ShouldRepeat(field, wiretype)) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h
index a055702c00..21521f8a91 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -51,6 +51,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -593,7 +594,7 @@ class PROTOC_EXPORT Formatter {
template ::value>::type>
static std::string ToString(I x) {
- return SimpleItoa(x);
+ return StrCat(x);
}
static std::string ToString(strings::Hex x) { return StrCat(x); }
static std::string ToString(const FieldDescriptor* d) { return Payload(d); }
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index b44677f5e6..86e4df3387 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -80,9 +80,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
(*variables)["val_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(val->type()));
(*variables)["map_classname"] = ClassName(descriptor->message_type(), false);
- (*variables)["number"] = SimpleItoa(descriptor->number());
- (*variables)["tag"] =
- SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["number"] = StrCat(descriptor->number());
+ (*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
if (HasDescriptorMethods(descriptor->file(), options)) {
(*variables)["lite"] = "";
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index 10aef2db16..ed20edd47c 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -246,8 +246,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) {
bool ShouldMarkClassAsFinal(const Descriptor* descriptor,
const Options& options) {
- const string name = ClassName(descriptor, true);
- return HasPrefixString(name, "::google::protobuf");
+ return true;
}
bool ShouldMarkClearAsFinal(const Descriptor* descriptor,
@@ -909,7 +908,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
format.Set("field_name", UnderscoresToCamelCase(field->name(), true));
format.Set("oneof_name", field->containing_oneof()->name());
format.Set("oneof_index",
- SimpleItoa(field->containing_oneof()->index()));
+ StrCat(field->containing_oneof()->index()));
GenerateOneofMemberHasBits(field, format);
} else {
// Singular field.
@@ -1342,8 +1341,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
const string has_bits_decl =
sizeof_has_bits == 0
? ""
- : "::$proto_ns$::internal::HasBits<" +
- SimpleItoa(sizeof_has_bits / 4) + "> _has_bits_;\n";
+ : StrCat("::$proto_ns$::internal::HasBits<",
+ sizeof_has_bits / 4, "> _has_bits_;\n");
// To minimize padding, data members are divided into three sections:
// (1) members assumed to align to 8 bytes
@@ -1634,10 +1633,9 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
std::map vars;
vars["classtype"] = QualifiedClassName(descriptor_);
vars["field_name"] = FieldName(field);
- vars["tag"] = SimpleItoa(tag);
- vars["hasbit"] = SimpleItoa(i);
- vars["type"] =
- SimpleItoa(CalcFieldNum(generator, field, options_));
+ vars["tag"] = StrCat(tag);
+ vars["hasbit"] = StrCat(i);
+ vars["type"] = StrCat(CalcFieldNum(generator, field, options_));
vars["ptr"] = "nullptr";
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
GOOGLE_CHECK(!IsMapEntryMessage(field->message_type()));
@@ -1646,8 +1644,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
"::" +
UniqueName("TableStruct", field->message_type(), options_) +
"::serialization_table + " +
- SimpleItoa(
- FindMessageIndexInFile(field->message_type()));
+ StrCat(FindMessageIndexInFile(field->message_type()));
}
}
Formatter::SaveState saver(&format);
@@ -1724,7 +1721,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
ptr =
"::" + UniqueName("TableStruct", field->message_type(), options_) +
"::serialization_table + " +
- SimpleItoa(FindMessageIndexInFile(field->message_type()));
+ StrCat(FindMessageIndexInFile(field->message_type()));
}
}
@@ -2172,16 +2169,15 @@ size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) {
std::map vars;
if (field->containing_oneof() != NULL) {
vars["name"] = field->containing_oneof()->name();
- vars["presence"] =
- SimpleItoa(field->containing_oneof()->index());
+ vars["presence"] = StrCat(field->containing_oneof()->index());
} else {
vars["name"] = FieldName(field);
- vars["presence"] = SimpleItoa(has_bit_indices_[field->index()]);
+ vars["presence"] = StrCat(has_bit_indices_[field->index()]);
}
- vars["nwtype"] = SimpleItoa(normal_wiretype);
- vars["pwtype"] = SimpleItoa(packed_wiretype);
- vars["ptype"] = SimpleItoa(processing_type);
- vars["tag_size"] = SimpleItoa(tag_size);
+ vars["nwtype"] = StrCat(normal_wiretype);
+ vars["pwtype"] = StrCat(packed_wiretype);
+ vars["ptype"] = StrCat(processing_type);
+ vars["tag_size"] = StrCat(tag_size);
format.AddMap(vars);
@@ -2336,9 +2332,8 @@ std::pair MessageGenerator::GenerateOffsets(
} else if (HasFieldPresence(descriptor_->file())) {
entries += has_bit_indices_.size();
for (int i = 0; i < has_bit_indices_.size(); i++) {
- const string index = has_bit_indices_[i] >= 0
- ? SimpleItoa(has_bit_indices_[i])
- : "~0u";
+ const string index =
+ has_bit_indices_[i] >= 0 ? StrCat(has_bit_indices_[i]) : "~0u";
format("$1$,\n", index);
}
}
@@ -3775,8 +3770,8 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range,
bool to_array) {
std::map vars;
- vars["start"] = SimpleItoa(range->start);
- vars["end"] = SimpleItoa(range->end);
+ vars["start"] = StrCat(range->start);
+ vars["end"] = StrCat(range->end);
Formatter format(printer, vars);
format("// Extension range [$start$, $end$)\n");
if (to_array) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 2f6a050455..a009a14ed7 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -38,6 +38,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -85,11 +86,10 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type());
(*variables)["default"] = DefaultValue(options, descriptor);
- (*variables)["tag"] =
- SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
int fixed_size = FixedSize(descriptor->type());
if (fixed_size != -1) {
- (*variables)["fixed_size"] = SimpleItoa(fixed_size);
+ (*variables)["fixed_size"] = StrCat(fixed_size);
}
(*variables)["wire_format_field_type"] = FieldDescriptorProto_Type_Name(
static_cast(descriptor->type()));
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index 74a3f34baa..3972ed25e3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -39,6 +39,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -52,7 +53,7 @@ void SetStringVariables(const FieldDescriptor* descriptor,
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["default"] = DefaultValue(options, descriptor);
(*variables)["default_length"] =
- SimpleItoa(descriptor->default_value_string().length());
+ StrCat(descriptor->default_value_string().length());
string default_variable_string = MakeDefaultName(descriptor);
(*variables)["default_variable_name"] = default_variable_string;
(*variables)["default_variable"] =
diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc
index 2528c2d13f..db795ed198 100644
--- a/src/google/protobuf/compiler/java/java_context.cc
+++ b/src/google/protobuf/compiler/java/java_context.cc
@@ -35,6 +35,7 @@
#include
#include
#include
+
#include
namespace google {
@@ -159,8 +160,8 @@ void Context::InitializeFieldGeneratorInfoForFields(
// For fields conflicting with some other fields, we append the field
// number to their field names in generated code to avoid conflicts.
if (is_conflict[i]) {
- info.name += SimpleItoa(field->number());
- info.capitalized_name += SimpleItoa(field->number());
+ info.name += StrCat(field->number());
+ info.capitalized_name += StrCat(field->number());
info.disambiguated_reason = conflict_reason[i];
}
field_generator_info_map_[field] = info;
diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc
index 1ca7ba958b..9436aa6633 100644
--- a/src/google/protobuf/compiler/java/java_enum.cc
+++ b/src/google/protobuf/compiler/java/java_enum.cc
@@ -44,6 +44,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -96,8 +97,8 @@ void EnumGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
std::map vars;
vars["name"] = canonical_values_[i]->name();
- vars["index"] = SimpleItoa(canonical_values_[i]->index());
- vars["number"] = SimpleItoa(canonical_values_[i]->number());
+ vars["index"] = StrCat(canonical_values_[i]->index());
+ vars["number"] = StrCat(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
if (canonical_values_[i]->options().deprecated()) {
printer->Print("@java.lang.Deprecated\n");
@@ -141,7 +142,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < descriptor_->value_count(); i++) {
std::map vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = SimpleItoa(descriptor_->value(i)->number());
+ vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
WriteEnumValueDocComment(printer, descriptor_->value(i));
@@ -192,7 +193,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
- SimpleItoa(canonical_values_[i]->number()));
+ StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
@@ -244,7 +245,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
" return $file$.getDescriptor().getEnumTypes().get($index$);\n",
"file",
name_resolver_->GetClassName(descriptor_->file(), immutable_api_),
- "index", SimpleItoa(descriptor_->index()));
+ "index", StrCat(descriptor_->index()));
} else {
printer->Print(
" return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
@@ -257,7 +258,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
.no_standard_descriptor_accessor()
? "getDefaultInstance().getDescriptorForType()"
: "getDescriptor()",
- "index", SimpleItoa(descriptor_->index()));
+ "index", StrCat(descriptor_->index()));
}
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc
index 9d0bcd2cec..35c9a316d0 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -46,6 +46,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -67,10 +68,10 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
name_resolver->GetMutableClassName(descriptor->enum_type());
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] =
- SimpleItoa(descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(
+ StrCat(descriptor->default_value_enum()->number());
+ (*variables)["tag"] = StrCat(
static_cast(internal::WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ (*variables)["tag_size"] = StrCat(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
@@ -358,7 +359,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void ImmutableEnumFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && $name$_ == other.$name$_;\n");
+ "if ($name$_ != other.$name$_) return false;\n");
}
void ImmutableEnumFieldGenerator::
@@ -554,12 +555,12 @@ void ImmutableEnumOneofFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "result = result && get$capitalized_name$Value()\n"
- " == other.get$capitalized_name$Value();\n");
+ "if (get$capitalized_name$Value()\n"
+ " != other.get$capitalized_name$Value()) return false;\n");
} else {
printer->Print(variables_,
- "result = result && get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$());\n");
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
}
}
@@ -983,7 +984,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void RepeatedImmutableEnumFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && $name$_.equals(other.$name$_);\n");
+ "if (!$name$_.equals(other.$name$_)) return false;\n");
}
void RepeatedImmutableEnumFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index 353a2f6e57..2b0ec2928a 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -46,6 +46,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -67,10 +68,10 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
name_resolver->GetMutableClassName(descriptor->enum_type());
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] =
- SimpleItoa(descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(
+ StrCat(descriptor->default_value_enum()->number());
+ (*variables)["tag"] = StrCat(
static_cast(internal::WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ (*variables)["tag_size"] = StrCat(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc
index deebe523c6..9db138373f 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -43,6 +43,7 @@
#include
#include
#include
+
#include
namespace google {
@@ -87,7 +88,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
std::map vars;
vars["name"] = canonical_values_[i]->name();
- vars["number"] = SimpleItoa(canonical_values_[i]->number());
+ vars["number"] = StrCat(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
if (canonical_values_[i]->options().deprecated()) {
printer->Print("@java.lang.Deprecated\n");
@@ -122,7 +123,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < descriptor_->value_count(); i++) {
std::map vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = SimpleItoa(descriptor_->value(i)->number());
+ vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
WriteEnumValueDocComment(printer, descriptor_->value(i));
@@ -166,7 +167,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
- SimpleItoa(canonical_values_[i]->number()));
+ StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc
index 1ee9771046..cc1921d5a4 100644
--- a/src/google/protobuf/compiler/java/java_extension.cc
+++ b/src/google/protobuf/compiler/java/java_extension.cc
@@ -41,6 +41,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -69,9 +70,9 @@ void ExtensionGenerator::InitTemplateVars(
vars["name"] = UnderscoresToCamelCase(descriptor);
vars["containing_type"] =
name_resolver->GetClassName(descriptor->containing_type(), immutable);
- vars["number"] = SimpleItoa(descriptor->number());
+ vars["number"] = StrCat(descriptor->number());
vars["constant_name"] = FieldConstantName(descriptor);
- vars["index"] = SimpleItoa(descriptor->index());
+ vars["index"] = StrCat(descriptor->index());
vars["default"] = descriptor->is_repeated() ?
"" : DefaultValue(descriptor, immutable, name_resolver);
vars["type_constant"] = FieldTypeName(GetType(descriptor));
@@ -152,7 +153,7 @@ int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
printer->Print(
"$name$.internalInit(descriptor.getExtensions().get($index$));\n",
"name", UnderscoresToCamelCase(descriptor_), "index",
- SimpleItoa(descriptor_->index()));
+ StrCat(descriptor_->index()));
bytecode_estimate += 21;
}
return bytecode_estimate;
diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc
index fec20a7f35..9574c151a2 100644
--- a/src/google/protobuf/compiler/java/java_field.cc
+++ b/src/google/protobuf/compiler/java/java_field.cc
@@ -55,6 +55,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -254,7 +255,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["capitalized_name"] = info->capitalized_name;
(*variables)["disambiguated_reason"] = info->disambiguated_reason;
(*variables)["constant_name"] = FieldConstantName(descriptor);
- (*variables)["number"] = SimpleItoa(descriptor->number());
+ (*variables)["number"] = StrCat(descriptor->number());
// These variables are placeholders to pick out the beginning and ends of
// identifiers for annotations (when doing so with existing variables would
// be ambiguous or impossible). They should never be set to anything but the
@@ -269,13 +270,13 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
(*variables)["oneof_name"] = info->name;
(*variables)["oneof_capitalized_name"] = info->capitalized_name;
(*variables)["oneof_index"] =
- SimpleItoa(descriptor->containing_oneof()->index());
+ StrCat(descriptor->containing_oneof()->index());
(*variables)["set_oneof_case_message"] =
- info->name + "Case_ = " + SimpleItoa(descriptor->number());
+ info->name + "Case_ = " + StrCat(descriptor->number());
(*variables)["clear_oneof_case_message"] = info->name +
"Case_ = 0";
(*variables)["has_oneof_case_message"] =
- info->name + "Case_ == " + SimpleItoa(descriptor->number());
+ info->name + "Case_ == " + StrCat(descriptor->number());
}
void PrintExtraFieldInfo(const std::map& variables,
diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc
index 5356512ced..d345ca9041 100644
--- a/src/google/protobuf/compiler/java/java_file.cc
+++ b/src/google/protobuf/compiler/java/java_file.cc
@@ -54,6 +54,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -172,11 +173,10 @@ void MaybeRestartJavaMethod(io::Printer* printer,
if ((*bytecode_estimate) > bytesPerMethod) {
++(*method_num);
- printer->Print(chain_statement, "method_num",
- SimpleItoa(*method_num));
+ printer->Print(chain_statement, "method_num", StrCat(*method_num));
printer->Outdent();
printer->Print("}\n");
- printer->Print(method_decl, "method_num", SimpleItoa(*method_num));
+ printer->Print(method_decl, "method_num", StrCat(*method_num));
printer->Indent();
*bytecode_estimate = 0;
}
@@ -548,13 +548,11 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(io::Printer*
" $scope$.getExtensions().get($index$),\n"
" (com.google.protobuf.Message) defaultExtensionInstance);\n"
"}\n",
- "scope", scope, "index", SimpleItoa(field->index()),
- "class",
+ "scope", scope, "index", StrCat(field->index()), "class",
name_resolver_->GetImmutableClassName(field->message_type()));
} else {
printer->Print("registry.add($scope$.getExtensions().get($index$));\n",
- "scope", scope, "index",
- SimpleItoa(field->index()));
+ "scope", scope, "index", StrCat(field->index()));
}
}
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc
index dbd1604a60..97ad0533e7 100644
--- a/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/src/google/protobuf/compiler/java/java_helpers.cc
@@ -46,6 +46,7 @@
#include
+
#include // for hash
namespace google {
@@ -473,16 +474,14 @@ string DefaultValue(const FieldDescriptor* field, bool immutable,
// of FieldDescriptor to call.
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return SimpleItoa(field->default_value_int32());
+ return StrCat(field->default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
// Need to print as a signed int since Java has no unsigned.
- return SimpleItoa(
- static_cast(field->default_value_uint32()));
+ return StrCat(static_cast(field->default_value_uint32()));
case FieldDescriptor::CPPTYPE_INT64:
- return SimpleItoa(field->default_value_int64()) + "L";
+ return StrCat(field->default_value_int64()) + "L";
case FieldDescriptor::CPPTYPE_UINT64:
- return SimpleItoa(
- static_cast(field->default_value_uint64())) +
+ return StrCat(static_cast(field->default_value_uint64())) +
"L";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
@@ -625,7 +624,7 @@ const char* bit_masks[] = {
string GetBitFieldName(int index) {
string varName = "bitField";
- varName += SimpleItoa(index);
+ varName += StrCat(index);
varName += "_";
return varName;
}
@@ -641,7 +640,7 @@ string GenerateGetBitInternal(const string& prefix, int bitIndex) {
int bitInVarIndex = bitIndex % 32;
string mask = bit_masks[bitInVarIndex];
- string result = "((" + varName + " & " + mask + ") == " + mask + ")";
+ string result = "((" + varName + " & " + mask + ") != 0)";
return result;
}
diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc
index b22a21993f..cfcb918d1a 100644
--- a/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/src/google/protobuf/compiler/java/java_map_field.cc
@@ -773,8 +773,8 @@ void ImmutableMapFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(
variables_,
- "result = result && internalGet$capitalized_name$().equals(\n"
- " other.internalGet$capitalized_name$());\n");
+ "if (!internalGet$capitalized_name$().equals(\n"
+ " other.internalGet$capitalized_name$())) return false;\n");
}
void ImmutableMapFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 151422310a..9aabd62a47 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -56,6 +56,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -109,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
std::map vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = SimpleItoa(descriptor_->index());
+ vars["index"] = StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(
@@ -153,7 +154,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
int bytecode_estimate = 0;
std::map vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = SimpleItoa(descriptor_->index());
+ vars["index"] = StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(
@@ -417,8 +418,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
descriptor_->oneof_decl(i))->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->capitalized_name;
- vars["oneof_index"] =
- SimpleItoa(descriptor_->oneof_decl(i)->index());
+ vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -434,7 +434,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"$deprecation$$field_name$($field_number$),\n", "deprecation",
field->options().deprecated() ? "@java.lang.Deprecated " : "",
"field_name", ToUpper(field->name()), "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
}
printer->Print(
"$cap_oneof_name$_NOT_SET(0);\n",
@@ -459,7 +459,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", SimpleItoa(field->number()),
+ "field_number", StrCat(field->number()),
"field_name", ToUpper(field->name()));
}
printer->Print(
@@ -491,8 +491,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
- "number",
- SimpleItoa(descriptor_->field(i)->number()));
+ "number", StrCat(descriptor_->field(i)->number()));
field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
printer->Print("\n");
}
@@ -764,7 +763,7 @@ void ImmutableMessageGenerator::GenerateSerializeOneField(
void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range) {
printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
- SimpleItoa(range->end));
+ StrCat(range->end));
}
// ===================================================================
@@ -838,7 +837,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
- "number", SimpleItoa(field->number()), "capitalized_name",
+ "number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -929,7 +928,7 @@ void ImmutableMessageGenerator::GenerateIsInitialized(
context_->GetOneofGeneratorInfo(oneof);
printer->Print("if ($oneof_name$Case_ == $field_number$) {\n",
"oneof_name", oneof_info->name, "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
} else {
printer->Print(
"if (has$name$()) {\n",
@@ -1023,7 +1022,6 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- printer->Print("boolean result = true;\n");
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->containing_oneof() == NULL) {
@@ -1031,7 +1029,7 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);
if (check_has_bits) {
printer->Print(
- "result = result && (has$name$() == other.has$name$());\n"
+ "if (has$name$() != other.has$name$()) return false;\n"
"if (has$name$()) {\n",
"name", info->capitalized_name);
printer->Indent();
@@ -1048,13 +1046,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
// Compare oneofs.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
printer->Print(
- "result = result && get$oneof_capitalized_name$Case().equals(\n"
- " other.get$oneof_capitalized_name$Case());\n",
+ "if (!get$oneof_capitalized_name$Case().equals("
+ "other.get$oneof_capitalized_name$Case())) return false;\n",
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->capitalized_name);
printer->Print(
- "if (!result) return false;\n"
"switch ($oneof_name$Case_) {\n",
"oneof_name",
context_->GetOneofGeneratorInfo(
@@ -1063,7 +1060,7 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
printer->Print("case $field_number$:\n", "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
printer->Indent();
field_generators_.get(field).GenerateEqualsCode(printer);
printer->Print("break;\n");
@@ -1080,14 +1077,14 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
// false for non-canonical ordering when running in LITE_RUNTIME but it's
// the best we can do.
printer->Print(
- "result = result && unknownFields.equals(other.unknownFields);\n");
+ "if (!unknownFields.equals(other.unknownFields)) return false;\n");
if (descriptor_->extension_range_count() > 0) {
printer->Print(
- "result = result &&\n"
- " getExtensionFields().equals(other.getExtensionFields());\n");
+ "if (!getExtensionFields().equals(other.getExtensionFields()))\n"
+ " return false;\n");
}
printer->Print(
- "return result;\n");
+ "return true;\n");
printer->Outdent();
printer->Print(
"}\n"
@@ -1145,7 +1142,7 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
printer->Print("case $field_number$:\n", "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
printer->Indent();
field_generators_.get(field).GenerateHashCode(printer);
printer->Print("break;\n");
@@ -1252,7 +1249,7 @@ GenerateParsingConstructor(io::Printer* printer) {
WireFormat::WireTypeForFieldType(field->type()));
printer->Print("case $tag$: {\n", "tag",
- SimpleItoa(static_cast(tag)));
+ StrCat(static_cast(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -1268,7 +1265,7 @@ GenerateParsingConstructor(io::Printer* printer) {
uint32 packed_tag = WireFormatLite::MakeTag(field->number(),
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print("case $tag$: {\n", "tag",
- SimpleItoa(static_cast(packed_tag)));
+ StrCat(static_cast(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc
index f2f6d0b28e..761be791c5 100644
--- a/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -54,6 +54,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -125,8 +126,7 @@ Generate(io::Printer* printer) {
descriptor_->oneof_decl(i))->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->capitalized_name;
- vars["oneof_index"] =
- SimpleItoa(descriptor_->oneof_decl(i)->index());
+ vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -233,7 +233,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
- "number", SimpleItoa(field->number()), "capitalized_name",
+ "number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -259,7 +259,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
printer->Print(
"case $number$:\n"
" return internalGetMutable$capitalized_name$();\n",
- "number", SimpleItoa(field->number()), "capitalized_name",
+ "number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -685,7 +685,7 @@ void MessageBuilderGenerator::GenerateIsInitialized(
context_->GetOneofGeneratorInfo(oneof);
printer->Print("if ($oneof_name$Case_ == $field_number$) {\n",
"oneof_name", oneof_info->name, "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
} else {
printer->Print(
"if (has$name$()) {\n",
diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index b9a12d4ad9..8987fa43de 100644
--- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -53,6 +53,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -101,8 +102,7 @@ Generate(io::Printer* printer) {
descriptor_->oneof_decl(i))->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->capitalized_name;
- vars["oneof_index"] =
- SimpleItoa(descriptor_->oneof_decl(i)->index());
+ vars["oneof_index"] = StrCat(descriptor_->oneof_decl(i)->index());
// oneofCase() and clearOneof()
printer->Print(vars,
diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc
index 92425d064e..5b6de09ac1 100644
--- a/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_message_field.cc
@@ -506,8 +506,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void ImmutableMessageFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$());\n");
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
}
void ImmutableMessageFieldGenerator::
@@ -1307,8 +1307,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void RepeatedImmutableMessageFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && get$capitalized_name$List()\n"
- " .equals(other.get$capitalized_name$List());\n");
+ "if (!get$capitalized_name$List()\n"
+ " .equals(other.get$capitalized_name$List())) return false;\n");
}
void RepeatedImmutableMessageFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc
index 7bf6426e81..58fbf15693 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -36,14 +36,15 @@
#include
#include
-#include
#include
#include
+#include
#include
#include
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index a131e8cca4..3f907e2210 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -56,6 +56,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -253,7 +254,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
oneof)->capitalized_name;
- vars["oneof_index"] = SimpleItoa(oneof->index());
+ vars["oneof_index"] = StrCat(oneof->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -267,7 +268,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
const FieldDescriptor* field = oneof->field(j);
printer->Print("$field_name$($field_number$),\n", "field_name",
ToUpper(field->name()), "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
}
printer->Print(
"$cap_oneof_name$_NOT_SET(0);\n",
@@ -292,7 +293,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", SimpleItoa(field->number()),
+ "field_number", StrCat(field->number()),
"field_name", ToUpper(field->name()));
}
printer->Print(
@@ -327,8 +328,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
- "number",
- SimpleItoa(descriptor_->field(i)->number()));
+ "number", StrCat(descriptor_->field(i)->number()));
field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
printer->Print("\n");
}
@@ -729,7 +729,7 @@ void ImmutableMessageLiteGenerator::GenerateSerializeOneField(
void ImmutableMessageLiteGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range) {
printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
- SimpleItoa(range->end));
+ StrCat(range->end));
}
// ===================================================================
@@ -810,7 +810,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized(
context_->GetOneofGeneratorInfo(oneof);
printer->Print("if ($oneof_name$Case_ == $field_number$) {\n",
"oneof_name", oneof_info->name, "field_number",
- SimpleItoa(field->number()));
+ StrCat(field->number()));
} else {
printer->Print(
"if (has$name$()) {\n",
@@ -1014,7 +1014,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
field->number(), WireFormat::WireTypeForFieldType(field->type()));
printer->Print("case $tag$: {\n", "tag",
- SimpleItoa(static_cast(tag)));
+ StrCat(static_cast(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -1031,7 +1031,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
uint32 packed_tag = WireFormatLite::MakeTag(
field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print("case $tag$: {\n", "tag",
- SimpleItoa(static_cast(packed_tag)));
+ StrCat(static_cast(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc
index a170a91006..b3ab52908d 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -46,6 +46,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -113,8 +114,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
(*variables)["tag"] =
- SimpleItoa(static_cast(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ StrCat(static_cast(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
if (IsReferenceType(GetJavaType(descriptor))) {
(*variables)["null_check"] =
@@ -130,7 +131,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
? "@java.lang.Deprecated " : "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = SimpleItoa(fixed_size);
+ (*variables)["fixed_size"] = StrCat(fixed_size);
}
(*variables)["on_changed"] = "onChanged();";
@@ -385,31 +386,29 @@ GenerateEqualsCode(io::Printer* printer) const {
case JAVATYPE_LONG:
case JAVATYPE_BOOLEAN:
printer->Print(variables_,
- "result = result && (get$capitalized_name$()\n"
- " == other.get$capitalized_name$());\n");
+ "if (get$capitalized_name$()\n"
+ " != other.get$capitalized_name$()) return false;\n");
break;
case JAVATYPE_FLOAT:
printer->Print(variables_,
- "result = result && (\n"
- " java.lang.Float.floatToIntBits(get$capitalized_name$())\n"
- " == java.lang.Float.floatToIntBits(\n"
- " other.get$capitalized_name$()));\n");
+ "if (java.lang.Float.floatToIntBits(get$capitalized_name$())\n"
+ " != java.lang.Float.floatToIntBits(\n"
+ " other.get$capitalized_name$())) return false;\n");
break;
case JAVATYPE_DOUBLE:
printer->Print(variables_,
- "result = result && (\n"
- " java.lang.Double.doubleToLongBits(get$capitalized_name$())\n"
- " == java.lang.Double.doubleToLongBits(\n"
- " other.get$capitalized_name$()));\n");
+ "if (java.lang.Double.doubleToLongBits(get$capitalized_name$())\n"
+ " != java.lang.Double.doubleToLongBits(\n"
+ " other.get$capitalized_name$())) return false;\n");
break;
case JAVATYPE_STRING:
case JAVATYPE_BYTES:
printer->Print(variables_,
- "result = result && get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$());\n");
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
break;
case JAVATYPE_ENUM:
@@ -926,8 +925,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void RepeatedImmutablePrimitiveFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && get$capitalized_name$List()\n"
- " .equals(other.get$capitalized_name$List());\n");
+ "if (!get$capitalized_name$List()\n"
+ " .equals(other.get$capitalized_name$List())) return false;\n");
}
void RepeatedImmutablePrimitiveFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index 034a0865b0..ce3488212b 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -46,6 +46,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -71,8 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
(*variables)["tag"] =
- SimpleItoa(static_cast(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ StrCat(static_cast(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
@@ -131,7 +132,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
? "@java.lang.Deprecated " : "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = SimpleItoa(fixed_size);
+ (*variables)["fixed_size"] = StrCat(fixed_size);
}
if (SupportFieldPresence(descriptor->file())) {
diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc
index 53a9017de4..36676f904f 100644
--- a/src/google/protobuf/compiler/java/java_service.cc
+++ b/src/google/protobuf/compiler/java/java_service.cc
@@ -41,6 +41,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -90,7 +91,7 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
" return $file$.getDescriptor().getServices().get($index$);\n"
"}\n",
"file", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "index", SimpleItoa(descriptor_->index()));
+ "index", StrCat(descriptor_->index()));
GenerateGetDescriptorForType(printer);
// Generate more stuff.
@@ -209,7 +210,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
std::map vars;
- vars["index"] = SimpleItoa(i);
+ vars["index"] = StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
method->input_type());
@@ -256,7 +257,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod(
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
std::map vars;
- vars["index"] = SimpleItoa(i);
+ vars["index"] = StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
method->input_type());
@@ -302,7 +303,7 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
std::map vars;
- vars["index"] = SimpleItoa(i);
+ vars["index"] = StrCat(i);
vars["type"] = name_resolver_->GetImmutableClassName(
(which == REQUEST) ? method->input_type() : method->output_type());
printer->Print(vars,
@@ -354,7 +355,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Indent();
std::map vars;
- vars["index"] = SimpleItoa(i);
+ vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
"channel.callMethod(\n"
@@ -418,7 +419,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Indent();
std::map vars;
- vars["index"] = SimpleItoa(i);
+ vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
"return ($output$) channel.callBlockingMethod(\n"
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index 2b6e938180..0184297b4c 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -47,6 +47,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -72,8 +73,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
(*variables)["tag"] =
- SimpleItoa(static_cast(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ StrCat(static_cast(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
" if (value == null) {\n"
@@ -451,8 +452,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void ImmutableStringFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$());\n");
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
}
void ImmutableStringFieldGenerator::
@@ -1016,8 +1017,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void RepeatedImmutableStringFieldGenerator::
GenerateEqualsCode(io::Printer* printer) const {
printer->Print(variables_,
- "result = result && get$capitalized_name$List()\n"
- " .equals(other.get$capitalized_name$List());\n");
+ "if (!get$capitalized_name$List()\n"
+ " .equals(other.get$capitalized_name$List())) return false;\n");
}
void RepeatedImmutableStringFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc
index 5ce3151791..29f5d05a61 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -47,6 +47,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -73,8 +74,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "java.lang.String";
(*variables)["tag"] =
- SimpleItoa(static_cast(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = SimpleItoa(
+ StrCat(static_cast(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
" if (value == null) {\n"
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 26645080d1..fd0367bc12 100644
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -43,6 +43,7 @@
#include
#include
#include
+
#include
#include
#include
@@ -615,12 +616,11 @@ string JSFieldIndex(const FieldDescriptor* field) {
for (int i = 0; i < parent_type->field_count(); i++) {
if (parent_type->field(i)->type() == FieldDescriptor::TYPE_GROUP &&
parent_type->field(i)->message_type() == containing_type) {
- return SimpleItoa(field->number() -
- parent_type->field(i)->number());
+ return StrCat(field->number() - parent_type->field(i)->number());
}
}
}
- return SimpleItoa(field->number());
+ return StrCat(field->number());
}
string JSOneofIndex(const OneofDescriptor* oneof) {
@@ -639,7 +639,7 @@ string JSOneofIndex(const OneofDescriptor* oneof) {
break;
}
}
- return SimpleItoa(index);
+ return StrCat(index);
}
// Decodes a codepoint in \x0000 -- \xFFFF.
@@ -845,23 +845,25 @@ string JSFieldDefault(const FieldDescriptor* field) {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return MaybeNumberString(
- field, SimpleItoa(field->default_value_int32()));
+ return MaybeNumberString(field,
+ StrCat(field->default_value_int32()));
case FieldDescriptor::CPPTYPE_UINT32:
// The original codegen is in Java, and Java protobufs store unsigned
// integer values as signed integer values. In order to exactly match the
// output, we need to reinterpret as base-2 signed. Ugh.
- return MaybeNumberString(field, SimpleItoa(static_cast(
- field->default_value_uint32())));
- case FieldDescriptor::CPPTYPE_INT64:
return MaybeNumberString(
- field, SimpleItoa(field->default_value_int64()));
+ field,
+ StrCat(static_cast(field->default_value_uint32())));
+ case FieldDescriptor::CPPTYPE_INT64:
+ return MaybeNumberString(field,
+ StrCat(field->default_value_int64()));
case FieldDescriptor::CPPTYPE_UINT64:
// See above note for uint32 -- reinterpreting as signed.
- return MaybeNumberString(field, SimpleItoa(static_cast(
- field->default_value_uint64())));
+ return MaybeNumberString(
+ field,
+ StrCat(static_cast(field->default_value_uint64())));
case FieldDescriptor::CPPTYPE_ENUM:
- return SimpleItoa(field->default_value_enum()->number());
+ return StrCat(field->default_value_enum()->number());
case FieldDescriptor::CPPTYPE_BOOL:
return field->default_value_bool() ? "true" : "false";
case FieldDescriptor::CPPTYPE_FLOAT:
@@ -1444,7 +1446,7 @@ string GetPivot(const Descriptor* desc) {
(max_field_number + 1) : kDefaultPivot;
}
- return SimpleItoa(pivot);
+ return StrCat(pivot);
}
// Whether this field represents presence. For fields with presence, we
@@ -2104,6 +2106,12 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options,
"};\n"
"goog.inherits($classname$, jspb.Message);\n"
"if (goog.DEBUG && !COMPILED) {\n"
+ // displayName overrides Function.prototype.displayName
+ // http://google3/javascript/externs/es3.js?l=511
+ " /**\n"
+ " * @public\n"
+ " * @override\n"
+ " */\n"
" $classname$.displayName = '$classname$';\n"
"}\n",
"classname", GetMessagePath(options, desc));
@@ -3128,8 +3136,7 @@ void Generator::GenerateClassDeserializeBinaryField(
const GeneratorOptions& options,
io::Printer* printer,
const FieldDescriptor* field) const {
- printer->Print(" case $num$:\n", "num",
- SimpleItoa(field->number()));
+ printer->Print(" case $num$:\n", "num", StrCat(field->number()));
if (field->is_map()) {
const FieldDescriptor* key_field = MapFieldKey(field);
@@ -3165,7 +3172,7 @@ void Generator::GenerateClassDeserializeBinaryField(
(field->type() == FieldDescriptor::TYPE_GROUP) ? "Group" : "Message",
"grpfield",
(field->type() == FieldDescriptor::TYPE_GROUP)
- ? (SimpleItoa(field->number()) + ", ")
+ ? (StrCat(field->number()) + ", ")
: "");
} else {
printer->Print(
@@ -3328,7 +3335,7 @@ void Generator::GenerateClassSerializeBinaryField(
printer->Print(
" f.serializeBinary($index$, writer, "
"$keyWriterFn$, $valueWriterFn$",
- "index", SimpleItoa(field->number()), "keyWriterFn",
+ "index", StrCat(field->number()), "keyWriterFn",
JSBinaryWriterMethodName(options, key_field), "valueWriterFn",
JSBinaryWriterMethodName(options, value_field));
@@ -3344,7 +3351,7 @@ void Generator::GenerateClassSerializeBinaryField(
" $index$,\n"
" f",
"method", JSBinaryReadWriteMethodName(field, /* is_writer = */ true),
- "index", SimpleItoa(field->number()));
+ "index", StrCat(field->number()));
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!field->is_map()) {
@@ -3381,7 +3388,7 @@ void Generator::GenerateEnum(const GeneratorOptions& options,
const EnumValueDescriptor* value = enumdesc->value(i);
printer->Print(" $name$: $value$$comma$\n", "name",
ToEnumCase(value->name()), "value",
- SimpleItoa(value->number()), "comma",
+ StrCat(value->number()), "comma",
(i == enumdesc->value_count() - 1) ? "" : ",");
printer->Annotate("name", value);
}
@@ -3425,8 +3432,8 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
"!Object} */ (\n"
" $toObject$),\n"
" $repeated$);\n",
- "index", SimpleItoa(field->number()), "name",
- extension_object_name, "ctor",
+ "index", StrCat(field->number()), "name", extension_object_name,
+ "ctor",
(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
? SubmessageTypeRef(options, field)
: string("null")),
@@ -3446,8 +3453,8 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
" $binaryMessageDeserializeFn$,\n",
"extendName",
JSExtensionsObjectName(options, field->file(), field->containing_type()),
- "index", SimpleItoa(field->number()), "class", extension_scope,
- "name", extension_object_name, "binaryReaderFn",
+ "index", StrCat(field->number()), "class", extension_scope, "name",
+ extension_object_name, "binaryReaderFn",
JSBinaryReaderMethodName(options, field), "binaryWriterFn",
JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn",
(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
@@ -3468,8 +3475,8 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
"\n",
"extendName",
JSExtensionsObjectName(options, field->file(), field->containing_type()),
- "index", SimpleItoa(field->number()), "class", extension_scope,
- "name", extension_object_name);
+ "index", StrCat(field->number()), "class", extension_scope, "name",
+ extension_object_name);
}
bool GeneratorOptions::ParseFromOptions(
diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc
index 1a3171a802..3f9fe2a436 100644
--- a/src/google/protobuf/compiler/parser.cc
+++ b/src/google/protobuf/compiler/parser.cc
@@ -38,6 +38,7 @@
#include
#include
+
#include
#include
@@ -1154,7 +1155,7 @@ bool Parser::ParseDefaultAssignment(
DO(ConsumeInteger64(max_value, &value,
"Expected integer for field default value."));
// And stringify it again.
- default_value->append(SimpleItoa(value));
+ default_value->append(StrCat(value));
break;
}
@@ -1177,7 +1178,7 @@ bool Parser::ParseDefaultAssignment(
DO(ConsumeInteger64(max_value, &value,
"Expected integer for field default value."));
// And stringify it again.
- default_value->append(SimpleItoa(value));
+ default_value->append(StrCat(value));
break;
}
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index 857eec7eae..745271be17 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -326,31 +326,22 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
// optional int32 major = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_major(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_major(value);
break;
}
// optional int32 minor = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_minor(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_minor(value);
break;
}
// optional int32 patch = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_patch(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_patch(value);
break;
}
// optional string suffix = 4;
@@ -359,16 +350,13 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.Version.suffix");
- auto str = msg->mutable_suffix();
+ object = msg->mutable_suffix();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -387,6 +375,10 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -809,16 +801,13 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
- auto str = msg->add_file_to_generate();
+ object = msg->add_file_to_generate();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
@@ -830,16 +819,13 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorRequest.parameter");
- auto str = msg->mutable_parameter();
+ object = msg->mutable_parameter();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -851,11 +837,9 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::compiler::Version::_InternalParse;
object = msg->mutable_compiler_version();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
@@ -867,11 +851,9 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::FileDescriptorProto::_InternalParse;
object = msg->add_proto_file();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 122 && (ptr += 1));
break;
@@ -891,6 +873,10 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1327,16 +1313,13 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1346,16 +1329,13 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
- auto str = msg->mutable_insertion_point();
+ object = msg->mutable_insertion_point();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1365,16 +1345,13 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.content");
- auto str = msg->mutable_content();
+ object = msg->mutable_content();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1393,6 +1370,10 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1779,16 +1760,13 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.error");
- auto str = msg->mutable_error();
+ object = msg->mutable_error();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1801,11 +1779,9 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::compiler::CodeGeneratorResponse_File::_InternalParse;
object = msg->add_file();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 122 && (ptr += 1));
break;
@@ -1825,6 +1801,10 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc
index bbe83525e0..6b1e4d2898 100644
--- a/src/google/protobuf/compiler/python/python_generator.cc
+++ b/src/google/protobuf/compiler/python/python_generator.cc
@@ -65,6 +65,7 @@
#include
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -218,13 +219,13 @@ string StringifyDefaultValue(const FieldDescriptor& field) {
switch (field.cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return SimpleItoa(field.default_value_int32());
+ return StrCat(field.default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
- return SimpleItoa(field.default_value_uint32());
+ return StrCat(field.default_value_uint32());
case FieldDescriptor::CPPTYPE_INT64:
- return SimpleItoa(field.default_value_int64());
+ return StrCat(field.default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64:
- return SimpleItoa(field.default_value_uint64());
+ return StrCat(field.default_value_uint64());
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field.default_value_double();
if (value == std::numeric_limits::infinity()) {
@@ -260,7 +261,7 @@ string StringifyDefaultValue(const FieldDescriptor& field) {
case FieldDescriptor::CPPTYPE_BOOL:
return field.default_value_bool() ? "True" : "False";
case FieldDescriptor::CPPTYPE_ENUM:
- return SimpleItoa(field.default_value_enum()->number());
+ return StrCat(field.default_value_enum()->number());
case FieldDescriptor::CPPTYPE_STRING:
//##!PY25 return "b\"" + CEscape(field.default_value_string()) +
//##!PY25 (field.type() != FieldDescriptor::TYPE_STRING ? "\"" :
@@ -495,7 +496,7 @@ void Generator::PrintTopLevelEnums() const {
for (int i = 0; i < top_level_enum_values.size(); ++i) {
printer_->Print("$name$ = $value$\n", "name",
top_level_enum_values[i].first, "value",
- SimpleItoa(top_level_enum_values[i].second));
+ StrCat(top_level_enum_values[i].second));
}
printer_->Print("\n");
}
@@ -569,7 +570,7 @@ void Generator::PrintTopLevelExtensions() const {
UpperString(&constant_name);
printer_->Print("$constant_name$ = $number$\n", "constant_name",
constant_name, "number",
- SimpleItoa(extension_field.number()));
+ StrCat(extension_field.number()));
printer_->Print("$name$ = ", "name", extension_field.name());
PrintFieldDescriptor(extension_field, is_extension);
printer_->Print("\n");
@@ -616,7 +617,7 @@ void Generator::PrintServiceDescriptor(
m["name"] = descriptor.name();
m["full_name"] = descriptor.full_name();
m["file"] = kDescriptorKey;
- m["index"] = SimpleItoa(descriptor.index());
+ m["index"] = StrCat(descriptor.index());
m["options_value"] = OptionsValue(options_string);
const char required_function_arguments[] =
"name='$name$',\n"
@@ -637,7 +638,7 @@ void Generator::PrintServiceDescriptor(
m.clear();
m["name"] = method->name();
m["full_name"] = method->full_name();
- m["index"] = SimpleItoa(method->index());
+ m["index"] = StrCat(method->index());
m["serialized_options"] = CEscape(options_string);
m["input_type"] = ModuleLevelDescriptorName(*(method->input_type()));
m["output_type"] = ModuleLevelDescriptorName(*(method->output_type()));
@@ -762,9 +763,8 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
for (int i = 0; i < message_descriptor.extension_range_count(); ++i) {
const Descriptor::ExtensionRange* range =
message_descriptor.extension_range(i);
- printer_->Print("($start$, $end$), ", "start",
- SimpleItoa(range->start), "end",
- SimpleItoa(range->end));
+ printer_->Print("($start$, $end$), ", "start", StrCat(range->start),
+ "end", StrCat(range->end));
}
printer_->Print("],\n");
printer_->Print("oneofs=[\n");
@@ -774,7 +774,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
std::map m;
m["name"] = desc->name();
m["full_name"] = desc->full_name();
- m["index"] = SimpleItoa(desc->index());
+ m["index"] = StrCat(desc->index());
string options_string =
OptionsValue(desc->options().SerializeAsString());
if (options_string == "None") {
@@ -1108,8 +1108,8 @@ void Generator::PrintEnumValueDescriptor(
descriptor.options().SerializeToString(&options_string);
std::map m;
m["name"] = descriptor.name();
- m["index"] = SimpleItoa(descriptor.index());
- m["number"] = SimpleItoa(descriptor.number());
+ m["index"] = StrCat(descriptor.index());
+ m["number"] = StrCat(descriptor.number());
m["options"] = OptionsValue(options_string);
printer_->Print(
m,
@@ -1137,11 +1137,11 @@ void Generator::PrintFieldDescriptor(
std::map m;
m["name"] = field.name();
m["full_name"] = field.full_name();
- m["index"] = SimpleItoa(field.index());
- m["number"] = SimpleItoa(field.number());
- m["type"] = SimpleItoa(field.type());
- m["cpp_type"] = SimpleItoa(field.cpp_type());
- m["label"] = SimpleItoa(field.label());
+ m["index"] = StrCat(field.index());
+ m["number"] = StrCat(field.number());
+ m["type"] = StrCat(field.type());
+ m["cpp_type"] = StrCat(field.cpp_type());
+ m["label"] = StrCat(field.label());
m["has_default_value"] = field.has_default_value() ? "True" : "False";
m["default_value"] = StringifyDefaultValue(field);
m["is_extension"] = is_extension ? "True" : "False";
@@ -1281,8 +1281,8 @@ void Generator::PrintSerializedPbInterval(
printer_->Print(
"serialized_start=$serialized_start$,\n"
"serialized_end=$serialized_end$,\n",
- "serialized_start", SimpleItoa(offset), "serialized_end",
- SimpleItoa(offset + sp.size()));
+ "serialized_start", StrCat(offset), "serialized_end",
+ StrCat(offset + sp.size()));
}
namespace {
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index caed8a94bd..606f8aca81 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -63,6 +63,7 @@
#include
+
#include
#include
#include
@@ -1926,16 +1927,16 @@ string FieldDescriptor::DefaultValueAsString(bool quote_string_type) const {
GOOGLE_CHECK(has_default_value()) << "No default value";
switch (cpp_type()) {
case CPPTYPE_INT32:
- return SimpleItoa(default_value_int32());
+ return StrCat(default_value_int32());
break;
case CPPTYPE_INT64:
- return SimpleItoa(default_value_int64());
+ return StrCat(default_value_int64());
break;
case CPPTYPE_UINT32:
- return SimpleItoa(default_value_uint32());
+ return StrCat(default_value_uint32());
break;
case CPPTYPE_UINT64:
- return SimpleItoa(default_value_uint64());
+ return StrCat(default_value_uint64());
break;
case CPPTYPE_FLOAT:
return SimpleFtoa(default_value_float());
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
index ac4d8b23eb..7da7546d9d 100644
--- a/src/google/protobuf/descriptor.h
+++ b/src/google/protobuf/descriptor.h
@@ -1135,10 +1135,8 @@ class PROTOBUF_EXPORT EnumValueDescriptor {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
};
-// Describes an RPC service. To get the ServiceDescriptor for a service,
-// call Service::GetDescriptor(). Generated service classes also have a
-// static method called descriptor() which returns the type's
-// ServiceDescriptor. Use DescriptorPool to construct your own descriptors.
+// Describes an RPC service. Use DescriptorPool to construct your own
+// descriptors.
class PROTOBUF_EXPORT ServiceDescriptor {
public:
typedef ServiceDescriptorProto Proto;
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index bba219b48d..b999c1ccb0 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -1486,11 +1486,9 @@ const char* FileDescriptorSet::_InternalParse(const char* begin, const char* end
parser_till_end = ::google::protobuf::FileDescriptorProto::_InternalParse;
object = msg->add_file();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
@@ -1939,16 +1937,13 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1958,16 +1953,13 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.package");
- auto str = msg->mutable_package();
+ object = msg->mutable_package();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1978,16 +1970,13 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.dependency");
- auto str = msg->add_dependency();
+ object = msg->add_dependency();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
@@ -2002,11 +1991,9 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::DescriptorProto::_InternalParse;
object = msg->add_message_type();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
@@ -2020,11 +2007,9 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::EnumDescriptorProto::_InternalParse;
object = msg->add_enum_type();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
@@ -2038,11 +2023,9 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::ServiceDescriptorProto::_InternalParse;
object = msg->add_service();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
@@ -2056,11 +2039,9 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_extension();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 58 && (ptr += 1));
break;
@@ -2073,11 +2054,9 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::FileOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
@@ -2088,22 +2067,17 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::SourceCodeInfo::_InternalParse;
object = msg->mutable_source_code_info();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated int32 public_dependency = 10;
case 10: {
if (static_cast<::google::protobuf::uint8>(tag) == 80) {
do {
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->add_public_dependency(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->add_public_dependency(value);
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 80 && (ptr += 1));
break;
@@ -2122,11 +2096,8 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
case 11: {
if (static_cast<::google::protobuf::uint8>(tag) == 88) {
do {
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->add_weak_dependency(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->add_weak_dependency(value);
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 88 && (ptr += 1));
break;
@@ -2147,16 +2118,13 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.syntax");
- auto str = msg->mutable_syntax();
+ object = msg->mutable_syntax();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -2175,6 +2143,10 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2982,21 +2954,15 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_start(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_start(value);
break;
}
// optional int32 end = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_end(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_end(value);
break;
}
// optional .google.protobuf.ExtensionRangeOptions options = 3;
@@ -3007,11 +2973,9 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
parser_till_end = ::google::protobuf::ExtensionRangeOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -3402,21 +3366,15 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* begin, con
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_start(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_start(value);
break;
}
// optional int32 end = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_end(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_end(value);
break;
}
default: {
@@ -3835,16 +3793,13 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.DescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -3857,11 +3812,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_field();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -3875,11 +3828,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::DescriptorProto::_InternalParse;
object = msg->add_nested_type();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
@@ -3893,11 +3844,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::EnumDescriptorProto::_InternalParse;
object = msg->add_enum_type();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
@@ -3911,11 +3860,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::DescriptorProto_ExtensionRange::_InternalParse;
object = msg->add_extension_range();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
@@ -3929,11 +3876,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_extension();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
@@ -3946,11 +3891,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::MessageOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
@@ -3962,11 +3905,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::OneofDescriptorProto::_InternalParse;
object = msg->add_oneof_decl();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 66 && (ptr += 1));
break;
@@ -3980,11 +3921,9 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::DescriptorProto_ReservedRange::_InternalParse;
object = msg->add_reserved_range();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 74 && (ptr += 1));
break;
@@ -3996,16 +3935,13 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.DescriptorProto.reserved_name");
- auto str = msg->add_reserved_name();
+ object = msg->add_reserved_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 82 && (ptr += 1));
@@ -4026,6 +3962,10 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -4712,11 +4652,9 @@ const char* ExtensionRangeOptions::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -5190,16 +5128,13 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -5209,55 +5144,45 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.extendee");
- auto str = msg->mutable_extendee();
+ object = msg->mutable_extendee();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional int32 number = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_number(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_number(value);
break;
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::FieldDescriptorProto_Label_IsValid(val)) {
::google::protobuf::internal::WriteVarint(4, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::FieldDescriptorProto_Label value = static_cast<::google::protobuf::FieldDescriptorProto_Label>(val);
- msg->set_label(value);
+ msg->set_label(static_cast<::google::protobuf::FieldDescriptorProto_Label>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::FieldDescriptorProto_Type_IsValid(val)) {
::google::protobuf::internal::WriteVarint(5, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::FieldDescriptorProto_Type value = static_cast<::google::protobuf::FieldDescriptorProto_Type>(val);
- msg->set_type(value);
+ msg->set_type(static_cast<::google::protobuf::FieldDescriptorProto_Type>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// optional string type_name = 6;
@@ -5266,16 +5191,13 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.type_name");
- auto str = msg->mutable_type_name();
+ object = msg->mutable_type_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -5285,16 +5207,13 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.default_value");
- auto str = msg->mutable_default_value();
+ object = msg->mutable_default_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -5306,21 +5225,16 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::FieldOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// optional int32 oneof_index = 9;
case 9: {
if (static_cast<::google::protobuf::uint8>(tag) != 72) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_oneof_index(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_oneof_index(value);
break;
}
// optional string json_name = 10;
@@ -5329,16 +5243,13 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.json_name");
- auto str = msg->mutable_json_name();
+ object = msg->mutable_json_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -5357,6 +5268,10 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -6094,16 +6009,13 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.OneofDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -6115,11 +6027,9 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::OneofOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -6137,6 +6047,10 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -6489,21 +6403,15 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* be
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_start(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_start(value);
break;
}
// optional int32 end = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_end(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_end(value);
break;
}
default: {
@@ -6902,16 +6810,13 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -6924,11 +6829,9 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::EnumValueDescriptorProto::_InternalParse;
object = msg->add_value();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -6941,11 +6844,9 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::EnumOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
@@ -6957,11 +6858,9 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::EnumDescriptorProto_EnumReservedRange::_InternalParse;
object = msg->add_reserved_range();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
@@ -6973,16 +6872,13 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumDescriptorProto.reserved_name");
- auto str = msg->add_reserved_name();
+ object = msg->add_reserved_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
@@ -7003,6 +6899,10 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -7529,27 +7429,21 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumValueDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional int32 number = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_number(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_number(value);
break;
}
// optional .google.protobuf.EnumValueOptions options = 3;
@@ -7560,11 +7454,9 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
parser_till_end = ::google::protobuf::EnumValueOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -7582,6 +7474,10 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -8010,16 +7906,13 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.ServiceDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -8032,11 +7925,9 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
parser_till_end = ::google::protobuf::MethodDescriptorProto::_InternalParse;
object = msg->add_method();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -8049,11 +7940,9 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
parser_till_end = ::google::protobuf::ServiceOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -8071,6 +7960,10 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -8546,16 +8439,13 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -8565,16 +8455,13 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.input_type");
- auto str = msg->mutable_input_type();
+ object = msg->mutable_input_type();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -8584,16 +8471,13 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.output_type");
- auto str = msg->mutable_output_type();
+ object = msg->mutable_output_type();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -8605,31 +8489,23 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
parser_till_end = ::google::protobuf::MethodOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// optional bool client_streaming = 5 [default = false];
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_client_streaming(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_client_streaming(value);
break;
}
// optional bool server_streaming = 6 [default = false];
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_server_streaming(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_server_streaming(value);
break;
}
default: {
@@ -8647,6 +8523,10 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -9355,16 +9235,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.java_package");
- auto str = msg->mutable_java_package();
+ object = msg->mutable_java_package();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9374,41 +9251,33 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.java_outer_classname");
- auto str = msg->mutable_java_outer_classname();
+ object = msg->mutable_java_outer_classname();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
case 9: {
if (static_cast<::google::protobuf::uint8>(tag) != 72) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::FileOptions_OptimizeMode_IsValid(val)) {
::google::protobuf::internal::WriteVarint(9, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::FileOptions_OptimizeMode value = static_cast<::google::protobuf::FileOptions_OptimizeMode>(val);
- msg->set_optimize_for(value);
+ msg->set_optimize_for(static_cast<::google::protobuf::FileOptions_OptimizeMode>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// optional bool java_multiple_files = 10 [default = false];
case 10: {
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_java_multiple_files(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_java_multiple_files(value);
break;
}
// optional string go_package = 11;
@@ -9417,87 +9286,63 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.go_package");
- auto str = msg->mutable_go_package();
+ object = msg->mutable_go_package();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional bool cc_generic_services = 16 [default = false];
case 16: {
if (static_cast<::google::protobuf::uint8>(tag) != 128) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_cc_generic_services(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_cc_generic_services(value);
break;
}
// optional bool java_generic_services = 17 [default = false];
case 17: {
if (static_cast<::google::protobuf::uint8>(tag) != 136) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_java_generic_services(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_java_generic_services(value);
break;
}
// optional bool py_generic_services = 18 [default = false];
case 18: {
if (static_cast<::google::protobuf::uint8>(tag) != 144) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_py_generic_services(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_py_generic_services(value);
break;
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
case 20: {
if (static_cast<::google::protobuf::uint8>(tag) != 160) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_java_generate_equals_and_hash(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_java_generate_equals_and_hash(value);
break;
}
// optional bool deprecated = 23 [default = false];
case 23: {
if (static_cast<::google::protobuf::uint8>(tag) != 184) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// optional bool java_string_check_utf8 = 27 [default = false];
case 27: {
if (static_cast<::google::protobuf::uint8>(tag) != 216) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_java_string_check_utf8(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_java_string_check_utf8(value);
break;
}
// optional bool cc_enable_arenas = 31 [default = false];
case 31: {
if (static_cast<::google::protobuf::uint8>(tag) != 248) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_cc_enable_arenas(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_cc_enable_arenas(value);
break;
}
// optional string objc_class_prefix = 36;
@@ -9506,16 +9351,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.objc_class_prefix");
- auto str = msg->mutable_objc_class_prefix();
+ object = msg->mutable_objc_class_prefix();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9525,16 +9367,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.csharp_namespace");
- auto str = msg->mutable_csharp_namespace();
+ object = msg->mutable_csharp_namespace();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9544,16 +9383,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.swift_prefix");
- auto str = msg->mutable_swift_prefix();
+ object = msg->mutable_swift_prefix();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9563,16 +9399,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_class_prefix");
- auto str = msg->mutable_php_class_prefix();
+ object = msg->mutable_php_class_prefix();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9582,27 +9415,21 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_namespace");
- auto str = msg->mutable_php_namespace();
+ object = msg->mutable_php_namespace();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional bool php_generic_services = 42 [default = false];
case 42: {
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_php_generic_services(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_php_generic_services(value);
break;
}
// optional string php_metadata_namespace = 44;
@@ -9611,16 +9438,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_metadata_namespace");
- auto str = msg->mutable_php_metadata_namespace();
+ object = msg->mutable_php_metadata_namespace();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9630,16 +9454,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.ruby_package");
- auto str = msg->mutable_ruby_package();
+ object = msg->mutable_ruby_package();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -9652,11 +9473,9 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -9684,6 +9503,10 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -10846,41 +10669,29 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
// optional bool message_set_wire_format = 1 [default = false];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_message_set_wire_format(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_message_set_wire_format(value);
break;
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_no_standard_descriptor_accessor(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_no_standard_descriptor_accessor(value);
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// optional bool map_entry = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_map_entry(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_map_entry(value);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -10892,11 +10703,9 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -11407,69 +11216,53 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::FieldOptions_CType_IsValid(val)) {
::google::protobuf::internal::WriteVarint(1, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::FieldOptions_CType value = static_cast<::google::protobuf::FieldOptions_CType>(val);
- msg->set_ctype(value);
+ msg->set_ctype(static_cast<::google::protobuf::FieldOptions_CType>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// optional bool packed = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_packed(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_packed(value);
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// optional bool lazy = 5 [default = false];
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_lazy(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_lazy(value);
break;
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::FieldOptions_JSType_IsValid(val)) {
::google::protobuf::internal::WriteVarint(6, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::FieldOptions_JSType value = static_cast<::google::protobuf::FieldOptions_JSType>(val);
- msg->set_jstype(value);
+ msg->set_jstype(static_cast<::google::protobuf::FieldOptions_JSType>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// optional bool weak = 10 [default = false];
case 10: {
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_weak(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_weak(value);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -11481,11 +11274,9 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -12048,11 +11839,9 @@ const char* OneofOptions::_InternalParse(const char* begin, const char* end, voi
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -12407,21 +12196,15 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
// optional bool allow_alias = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_allow_alias(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_allow_alias(value);
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -12433,11 +12216,9 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -12855,11 +12636,8 @@ const char* EnumValueOptions::_InternalParse(const char* begin, const char* end,
// optional bool deprecated = 1 [default = false];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -12871,11 +12649,9 @@ const char* EnumValueOptions::_InternalParse(const char* begin, const char* end,
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -13255,11 +13031,8 @@ const char* ServiceOptions::_InternalParse(const char* begin, const char* end, v
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -13271,11 +13044,9 @@ const char* ServiceOptions::_InternalParse(const char* begin, const char* end, v
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -13668,25 +13439,20 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_deprecated(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_deprecated(value);
break;
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
case 34: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
if (!::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(val)) {
::google::protobuf::internal::WriteVarint(34, val, msg->mutable_unknown_fields());
break;
}
- ::google::protobuf::MethodOptions_IdempotencyLevel value = static_cast<::google::protobuf::MethodOptions_IdempotencyLevel>(val);
- msg->set_idempotency_level(value);
+ msg->set_idempotency_level(static_cast<::google::protobuf::MethodOptions_IdempotencyLevel>(val));
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -13698,11 +13464,9 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
@@ -14140,27 +13904,21 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.NamePart.name_part");
- auto str = msg->mutable_name_part();
+ object = msg->mutable_name_part();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// required bool is_extension = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_is_extension(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_is_extension(value);
break;
}
default: {
@@ -14178,6 +13936,10 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -14601,11 +14363,9 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
parser_till_end = ::google::protobuf::UninterpretedOption_NamePart::_InternalParse;
object = msg->add_name();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -14616,46 +14376,35 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.identifier_value");
- auto str = msg->mutable_identifier_value();
+ object = msg->mutable_identifier_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional uint64 positive_int_value = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_positive_int_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::uint64 value = val;
- msg->set_positive_int_value(value);
break;
}
// optional int64 negative_int_value = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_negative_int_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int64 value = val;
- msg->set_negative_int_value(value);
break;
}
// optional double double_value = 6;
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 49) goto handle_unusual;
- double val;
- ::std::memcpy(&val, ptr, 8);
- ptr += 8;
- msg->set_double_value(val);
+ msg->set_double_value(::google::protobuf::io::UnalignedLoad(ptr));
+ ptr += sizeof(double);
break;
}
// optional bytes string_value = 7;
@@ -14663,16 +14412,13 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- auto str = msg->mutable_string_value();
+ object = msg->mutable_string_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParser;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheck(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -14682,16 +14428,13 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.aggregate_value");
- auto str = msg->mutable_aggregate_value();
+ object = msg->mutable_aggregate_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -14710,6 +14453,10 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -15287,11 +15034,8 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
do {
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->add_path(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->add_path(value);
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 8 && (ptr += 1));
break;
@@ -15310,11 +15054,8 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
do {
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->add_span(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->add_span(value);
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 16 && (ptr += 1));
break;
@@ -15325,16 +15066,13 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.leading_comments");
- auto str = msg->mutable_leading_comments();
+ object = msg->mutable_leading_comments();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -15344,16 +15082,13 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.trailing_comments");
- auto str = msg->mutable_trailing_comments();
+ object = msg->mutable_trailing_comments();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -15364,16 +15099,13 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
- auto str = msg->add_leading_detached_comments();
+ object = msg->add_leading_detached_comments();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
@@ -15394,6 +15126,10 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -15908,11 +15644,9 @@ const char* SourceCodeInfo::_InternalParse(const char* begin, const char* end, v
parser_till_end = ::google::protobuf::SourceCodeInfo_Location::_InternalParse;
object = msg->add_location();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
@@ -16262,11 +15996,8 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
do {
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->add_path(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->add_path(value);
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 8 && (ptr += 1));
break;
@@ -16277,37 +16008,28 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.GeneratedCodeInfo.Annotation.source_file");
- auto str = msg->mutable_source_file();
+ object = msg->mutable_source_file();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8Verify;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8Verify(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// optional int32 begin = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_begin(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_begin(value);
break;
}
// optional int32 end = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_end(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_end(value);
break;
}
default: {
@@ -16325,6 +16047,10 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -16757,11 +16483,9 @@ const char* GeneratedCodeInfo::_InternalParse(const char* begin, const char* end
parser_till_end = ::google::protobuf::GeneratedCodeInfo_Annotation::_InternalParse;
object = msg->add_annotation();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc
index d4a0cb1172..1e29f3c164 100644
--- a/src/google/protobuf/duration.pb.cc
+++ b/src/google/protobuf/duration.pb.cc
@@ -188,21 +188,15 @@ const char* Duration::_InternalParse(const char* begin, const char* end, void* o
// int64 seconds = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_seconds(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int64 value = val;
- msg->set_seconds(value);
break;
}
// int32 nanos = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_nanos(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_nanos(value);
break;
}
default: {
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc
index b865a50c66..e5a8fe6f59 100644
--- a/src/google/protobuf/field_mask.pb.cc
+++ b/src/google/protobuf/field_mask.pb.cc
@@ -186,16 +186,13 @@ const char* FieldMask::_InternalParse(const char* begin, const char* end, void*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldMask.paths");
- auto str = msg->add_paths();
+ object = msg->add_paths();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
@@ -216,6 +213,10 @@ const char* FieldMask::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index 2e29fd3842..6230153a21 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -219,10 +219,10 @@ inline void OnShutdownDestroyString(const ::std::string* ptr) {
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-
-inline void InlineGreedyStringParser(std::string* str, const char* begin, int size,
- ParseContext*) {
- str->assign(begin, size);
+// To simplify generation of the parse loop code we take objects by void ptr.
+inline void InlineGreedyStringParser(void* str, const char* begin, int size,
+ ParseContext*) {
+ static_cast(str)->assign(begin, size);
}
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 8d80d19f17..d75095d9ff 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -183,6 +183,7 @@ const char* VarintParse(const char* p, T* out) {
}
extra += 128ull << (i * 7);
}
+ *out = 0;
return nullptr;
}
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index a7126c1639..624f84d13f 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -559,6 +559,7 @@ class Map {
iterator find(const Key& k) { return iterator(FindHelper(k).first); }
const_iterator find(const Key& k) const { return find(k, NULL); }
+ bool contains(const Key& k) const { return find(k) != end(); }
// In traditional C++ style, this performs "insert if not present."
std::pair insert(const KeyValuePair& kv) {
@@ -1079,6 +1080,7 @@ class Map {
return const_iterator(iterator(elements_->find(key)));
}
iterator find(const key_type& key) { return iterator(elements_->find(key)); }
+ bool contains(const Key& key) const { return elements_->contains(key); }
std::pair equal_range(
const key_type& key) const {
const_iterator it = find(key);
diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc
index 06ebf5d3f8..1cb133829b 100644
--- a/src/google/protobuf/map_test.cc
+++ b/src/google/protobuf/map_test.cc
@@ -126,6 +126,7 @@ class MapImplTest : public ::testing::Test {
// Test map size is correct.
EXPECT_EQ(value, map_[key]);
EXPECT_EQ(1, map_.count(key));
+ EXPECT_TRUE(map_.contains(key));
// Check mutable at and find work correctly.
EXPECT_EQ(value, map_.at(key));
@@ -248,6 +249,14 @@ TEST_F(MapImplTest, CountNonExist) {
EXPECT_EQ(0, map_.count(0));
}
+TEST_F(MapImplTest, ContainNotExist) {
+ EXPECT_FALSE(map_.contains(0));
+}
+
+TEST_F(MapImplTest, ImmutableContainNotExist) {
+ EXPECT_FALSE(const_map_.contains(0));
+}
+
TEST_F(MapImplTest, MutableFindNonExist) {
EXPECT_TRUE(map_.end() == map_.find(0));
}
diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h
index 20195bdc0d..43e4144c97 100644
--- a/src/google/protobuf/parse_context.h
+++ b/src/google/protobuf/parse_context.h
@@ -137,7 +137,9 @@ struct ParseClosure {
// (end <= retval < end + kSlopBytes).
// All tag/value pairs between in [begin, retval) are parsed and retval
// points to start of a tag.
- const char* operator()(const char* ptr, const char* end, ParseContext* ctx) {
+ PROTOBUF_ALWAYS_INLINE // Don't pay for extra stack frame in debug mode
+ const char*
+ operator()(const char* ptr, const char* end, ParseContext* ctx) {
GOOGLE_DCHECK(ptr < end);
return func(ptr, end, object, ctx);
}
diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc
index 541fee943c..058f58f3ee 100644
--- a/src/google/protobuf/reflection_ops.cc
+++ b/src/google/protobuf/reflection_ops.cc
@@ -45,6 +45,7 @@
#include
#include
+
namespace google {
namespace protobuf {
namespace internal {
@@ -288,7 +289,7 @@ static string SubMessagePrefix(const string& prefix,
}
if (index != -1) {
result.append("[");
- result.append(SimpleItoa(index));
+ result.append(StrCat(index));
result.append("]");
}
result.append(".");
diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc
index fa86c593b3..033e3436f7 100644
--- a/src/google/protobuf/repeated_field_unittest.cc
+++ b/src/google/protobuf/repeated_field_unittest.cc
@@ -49,6 +49,7 @@
#include
#include
#include
+
#include
namespace google {
@@ -1786,11 +1787,11 @@ TEST_F(RepeatedFieldInsertionIteratorsTest,
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
string* new_data = new string;
- *new_data = "name-" + SimpleItoa(i);
+ *new_data = "name-" + StrCat(i);
data.push_back(new_data);
new_data = goldenproto.add_repeated_string();
- *new_data = "name-" + SimpleItoa(i);
+ *new_data = "name-" + StrCat(i);
}
TestAllTypes testproto;
std::copy(data.begin(), data.end(), AllocatedRepeatedPtrFieldBackInserter(
@@ -1823,11 +1824,11 @@ TEST_F(RepeatedFieldInsertionIteratorsTest,
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
string* new_data = new string;
- *new_data = "name-" + SimpleItoa(i);
+ *new_data = "name-" + StrCat(i);
data.push_back(new_data);
new_data = goldenproto.add_repeated_string();
- *new_data = "name-" + SimpleItoa(i);
+ *new_data = "name-" + StrCat(i);
}
TestAllTypes testproto;
std::copy(data.begin(), data.end(),
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc
index e779fc961a..89faa46613 100644
--- a/src/google/protobuf/source_context.pb.cc
+++ b/src/google/protobuf/source_context.pb.cc
@@ -176,16 +176,13 @@ const char* SourceContext::_InternalParse(const char* begin, const char* end, vo
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceContext.file_name");
- auto str = msg->mutable_file_name();
+ object = msg->mutable_file_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -204,6 +201,10 @@ const char* SourceContext::_InternalParse(const char* begin, const char* end, vo
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc
index 9e1740c23a..c0fd3f3690 100644
--- a/src/google/protobuf/struct.pb.cc
+++ b/src/google/protobuf/struct.pb.cc
@@ -856,20 +856,16 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
// .google.protobuf.NullValue null_value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_null_value(static_cast<::google::protobuf::NullValue>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::NullValue value = static_cast<::google::protobuf::NullValue>(val);
- msg->set_null_value(value);
break;
}
// double number_value = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 17) goto handle_unusual;
- double val;
- ::std::memcpy(&val, ptr, 8);
- ptr += 8;
- msg->set_number_value(val);
+ msg->set_number_value(::google::protobuf::io::UnalignedLoad(ptr));
+ ptr += sizeof(double);
break;
}
// string string_value = 3;
@@ -878,27 +874,21 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Value.string_value");
- auto str = msg->mutable_string_value();
+ object = msg->mutable_string_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// bool bool_value = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_bool_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_bool_value(value);
break;
}
// .google.protobuf.Struct struct_value = 5;
@@ -909,11 +899,9 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
parser_till_end = ::google::protobuf::Struct::_InternalParse;
object = msg->mutable_struct_value();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.protobuf.ListValue list_value = 6;
@@ -924,11 +912,9 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
parser_till_end = ::google::protobuf::ListValue::_InternalParse;
object = msg->mutable_list_value();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -946,6 +932,10 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1424,11 +1414,9 @@ const char* ListValue::_InternalParse(const char* begin, const char* end, void*
parser_till_end = ::google::protobuf::Value::_InternalParse;
object = msg->add_values();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 50e2b1cb3c..e4b9b455e2 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -764,7 +764,7 @@ label_skip_parsing:
LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
int64 int_value;
DO(ConsumeSignedInteger(&int_value, kint32max));
- value = SimpleItoa(int_value); // for error reporting
+ value = StrCat(int_value); // for error reporting
enum_value = enum_type->FindValueByNumber(int_value);
} else {
ReportError("Expected integer or identifier, got: " +
@@ -1575,19 +1575,19 @@ void TextFormat::FastFieldValuePrinter::PrintBool(
}
void TextFormat::FastFieldValuePrinter::PrintInt32(
int32 val, BaseTextGenerator* generator) const {
- generator->PrintString(SimpleItoa(val));
+ generator->PrintString(StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintUInt32(
uint32 val, BaseTextGenerator* generator) const {
- generator->PrintString(SimpleItoa(val));
+ generator->PrintString(StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintInt64(
int64 val, BaseTextGenerator* generator) const {
- generator->PrintString(SimpleItoa(val));
+ generator->PrintString(StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintUInt64(
uint64 val, BaseTextGenerator* generator) const {
- generator->PrintString(SimpleItoa(val));
+ generator->PrintString(StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintFloat(
float val, BaseTextGenerator* generator) const {
@@ -2251,7 +2251,7 @@ void TextFormat::Printer::PrintFieldName(const Message& message,
// if use_field_number_ is true, prints field number instead
// of field name.
if (use_field_number_) {
- generator->PrintString(SimpleItoa(field->number()));
+ generator->PrintString(StrCat(field->number()));
return;
}
@@ -2396,13 +2396,13 @@ void TextFormat::Printer::PrintUnknownFields(
const UnknownFieldSet& unknown_fields, TextGenerator* generator) const {
for (int i = 0; i < unknown_fields.field_count(); i++) {
const UnknownField& field = unknown_fields.field(i);
- string field_number = SimpleItoa(field.number());
+ string field_number = StrCat(field.number());
switch (field.type()) {
case UnknownField::TYPE_VARINT:
generator->PrintString(field_number);
generator->PrintLiteral(": ");
- generator->PrintString(SimpleItoa(field.varint()));
+ generator->PrintString(StrCat(field.varint()));
if (single_line_mode_) {
generator->PrintLiteral(" ");
} else {
diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc
index d64cd2ebec..883875a79b 100644
--- a/src/google/protobuf/text_format_unittest.cc
+++ b/src/google/protobuf/text_format_unittest.cc
@@ -54,6 +54,7 @@
#include
#include
+
#include
#include
#include
@@ -1284,9 +1285,9 @@ class TextFormatParserTest : public testing::Test {
parser.RecordErrorsTo(&error_collector);
EXPECT_EQ(expected_result, parser.ParseFromString(input, proto))
<< input << " -> " << proto->DebugString();
- EXPECT_EQ(SimpleItoa(line) + ":" + SimpleItoa(col) +
- ": " + message + "\n",
- error_collector.text_);
+ EXPECT_EQ(
+ StrCat(line) + ":" + StrCat(col) + ": " + message + "\n",
+ error_collector.text_);
}
void ExpectSuccessAndTree(const string& input, Message* proto,
@@ -1509,7 +1510,7 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) {
// enum
EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAR, "BAR");
EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAZ,
- SimpleItoa(unittest::TestAllTypes::BAZ));
+ StrCat(unittest::TestAllTypes::BAZ));
EXPECT_INVALID(nested_enum, "FOOBAR");
// message
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc
index acc7b9b8dd..6cc150baf9 100644
--- a/src/google/protobuf/timestamp.pb.cc
+++ b/src/google/protobuf/timestamp.pb.cc
@@ -188,21 +188,15 @@ const char* Timestamp::_InternalParse(const char* begin, const char* end, void*
// int64 seconds = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_seconds(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int64 value = val;
- msg->set_seconds(value);
break;
}
// int32 nanos = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_nanos(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_nanos(value);
break;
}
default: {
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc
index c187394719..bc31823a17 100644
--- a/src/google/protobuf/type.pb.cc
+++ b/src/google/protobuf/type.pb.cc
@@ -518,16 +518,13 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Type.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -540,11 +537,9 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::Field::_InternalParse;
object = msg->add_fields();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -556,16 +551,13 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Type.oneofs");
- auto str = msg->add_oneofs();
+ object = msg->add_oneofs();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
@@ -580,11 +572,9 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
@@ -597,21 +587,17 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.protobuf.Syntax syntax = 6;
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_syntax(static_cast<::google::protobuf::Syntax>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
- msg->set_syntax(value);
break;
}
default: {
@@ -629,6 +615,10 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1167,31 +1157,24 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
// .google.protobuf.Field.Kind kind = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_kind(static_cast<::google::protobuf::Field_Kind>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Field_Kind value = static_cast<::google::protobuf::Field_Kind>(val);
- msg->set_kind(value);
break;
}
// .google.protobuf.Field.Cardinality cardinality = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_cardinality(static_cast<::google::protobuf::Field_Cardinality>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Field_Cardinality value = static_cast<::google::protobuf::Field_Cardinality>(val);
- msg->set_cardinality(value);
break;
}
// int32 number = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_number(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_number(value);
break;
}
// string name = 4;
@@ -1200,16 +1183,13 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1219,37 +1199,28 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.type_url");
- auto str = msg->mutable_type_url();
+ object = msg->mutable_type_url();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// int32 oneof_index = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_oneof_index(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_oneof_index(value);
break;
}
// bool packed = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 64) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_packed(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_packed(value);
break;
}
// repeated .google.protobuf.Option options = 9;
@@ -1261,11 +1232,9 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 74 && (ptr += 1));
break;
@@ -1276,16 +1245,13 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.json_name");
- auto str = msg->mutable_json_name();
+ object = msg->mutable_json_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1295,16 +1261,13 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.default_value");
- auto str = msg->mutable_default_value();
+ object = msg->mutable_default_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -1323,6 +1286,10 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2028,16 +1995,13 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Enum.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -2050,11 +2014,9 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::EnumValue::_InternalParse;
object = msg->add_enumvalue();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
@@ -2068,11 +2030,9 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
@@ -2085,21 +2045,17 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.protobuf.Syntax syntax = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+ msg->set_syntax(static_cast<::google::protobuf::Syntax>(val));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
- msg->set_syntax(value);
break;
}
default: {
@@ -2117,6 +2073,10 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2575,27 +2535,21 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumValue.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
// int32 number = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_number(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_number(value);
break;
}
// repeated .google.protobuf.Option options = 3;
@@ -2607,11 +2561,9 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
@@ -2631,6 +2583,10 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -3041,16 +2997,13 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Option.name");
- auto str = msg->mutable_name();
+ object = msg->mutable_name();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -3062,11 +3015,9 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
parser_till_end = ::google::protobuf::Any::_InternalParse;
object = msg->mutable_value();
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- bool ok = ctx->ParseExactRange({parser_till_end, object},
- ptr, newend);
- GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
- ptr = newend;
+ ptr += size;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+ {parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
@@ -3084,6 +3035,10 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc
index 40827cbc97..2ae447feef 100644
--- a/src/google/protobuf/util/internal/datapiece.cc
+++ b/src/google/protobuf/util/internal/datapiece.cc
@@ -34,6 +34,7 @@
#include
#include
#include
+
#include
#include
#include
@@ -231,13 +232,13 @@ string DataPiece::ValueAsStringOrDefault(
StringPiece default_string) const {
switch (type_) {
case TYPE_INT32:
- return SimpleItoa(i32_);
+ return StrCat(i32_);
case TYPE_INT64:
- return SimpleItoa(i64_);
+ return StrCat(i64_);
case TYPE_UINT32:
- return SimpleItoa(u32_);
+ return StrCat(u32_);
case TYPE_UINT64:
- return SimpleItoa(u64_);
+ return StrCat(u64_);
case TYPE_DOUBLE:
return DoubleAsString(double_);
case TYPE_FLOAT:
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc
index c2d3292eb1..74c9e74128 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -36,6 +36,7 @@
#include
#include
#include
+
#include
#include
#include
@@ -89,19 +90,19 @@ JsonObjectWriter* JsonObjectWriter::RenderBool(StringPiece name,
JsonObjectWriter* JsonObjectWriter::RenderInt32(StringPiece name,
int32 value) {
- return RenderSimple(name, SimpleItoa(value));
+ return RenderSimple(name, StrCat(value));
}
JsonObjectWriter* JsonObjectWriter::RenderUint32(StringPiece name,
uint32 value) {
- return RenderSimple(name, SimpleItoa(value));
+ return RenderSimple(name, StrCat(value));
}
JsonObjectWriter* JsonObjectWriter::RenderInt64(StringPiece name,
int64 value) {
WritePrefix(name);
WriteChar('"');
- stream_->WriteString(SimpleItoa(value));
+ stream_->WriteString(StrCat(value));
WriteChar('"');
return this;
}
@@ -110,7 +111,7 @@ JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name,
uint64 value) {
WritePrefix(name);
WriteChar('"');
- stream_->WriteString(SimpleItoa(value));
+ stream_->WriteString(StrCat(value));
WriteChar('"');
return this;
}
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 2c1a739300..a37d0eb976 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -49,6 +49,7 @@
#include
#include
+
#include
#include
@@ -943,61 +944,61 @@ const string ProtoStreamObjectSource::ReadFieldValueAsString(
case google::protobuf::Field_Kind_TYPE_INT32: {
uint32 buffer32;
stream_->ReadVarint32(&buffer32);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer32));
+ result = StrCat(::google::protobuf::bit_cast(buffer32));
break;
}
case google::protobuf::Field_Kind_TYPE_INT64: {
uint64 buffer64;
stream_->ReadVarint64(&buffer64);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer64));
+ result = StrCat(::google::protobuf::bit_cast(buffer64));
break;
}
case google::protobuf::Field_Kind_TYPE_UINT32: {
uint32 buffer32;
stream_->ReadVarint32(&buffer32);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer32));
+ result = StrCat(::google::protobuf::bit_cast(buffer32));
break;
}
case google::protobuf::Field_Kind_TYPE_UINT64: {
uint64 buffer64;
stream_->ReadVarint64(&buffer64);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer64));
+ result = StrCat(::google::protobuf::bit_cast(buffer64));
break;
}
case google::protobuf::Field_Kind_TYPE_SINT32: {
uint32 buffer32;
stream_->ReadVarint32(&buffer32);
- result = SimpleItoa(WireFormatLite::ZigZagDecode32(buffer32));
+ result = StrCat(WireFormatLite::ZigZagDecode32(buffer32));
break;
}
case google::protobuf::Field_Kind_TYPE_SINT64: {
uint64 buffer64;
stream_->ReadVarint64(&buffer64);
- result = SimpleItoa(WireFormatLite::ZigZagDecode64(buffer64));
+ result = StrCat(WireFormatLite::ZigZagDecode64(buffer64));
break;
}
case google::protobuf::Field_Kind_TYPE_SFIXED32: {
uint32 buffer32;
stream_->ReadLittleEndian32(&buffer32);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer32));
+ result = StrCat(::google::protobuf::bit_cast(buffer32));
break;
}
case google::protobuf::Field_Kind_TYPE_SFIXED64: {
uint64 buffer64;
stream_->ReadLittleEndian64(&buffer64);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer64));
+ result = StrCat(::google::protobuf::bit_cast(buffer64));
break;
}
case google::protobuf::Field_Kind_TYPE_FIXED32: {
uint32 buffer32;
stream_->ReadLittleEndian32(&buffer32);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer32));
+ result = StrCat(::google::protobuf::bit_cast(buffer32));
break;
}
case google::protobuf::Field_Kind_TYPE_FIXED64: {
uint64 buffer64;
stream_->ReadLittleEndian64(&buffer64);
- result = SimpleItoa(::google::protobuf::bit_cast(buffer64));
+ result = StrCat(::google::protobuf::bit_cast(buffer64));
break;
}
case google::protobuf::Field_Kind_TYPE_FLOAT: {
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
index 9f0e2089d6..65115133cf 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -44,6 +44,7 @@
#include
#include
+
#include
#include
@@ -887,7 +888,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow,
if (int_value.ok()) {
ow->ProtoWriter::RenderDataPiece(
"string_value",
- DataPiece(SimpleItoa(int_value.ValueOrDie()), true));
+ DataPiece(StrCat(int_value.ValueOrDie()), true));
return Status();
}
}
@@ -902,7 +903,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow,
if (int_value.ok()) {
ow->ProtoWriter::RenderDataPiece(
"string_value",
- DataPiece(SimpleItoa(int_value.ValueOrDie()), true));
+ DataPiece(StrCat(int_value.ValueOrDie()), true));
return Status();
}
}
diff --git a/src/google/protobuf/util/internal/utility.h b/src/google/protobuf/util/internal/utility.h
index 29935d6f70..8cd695f2ee 100644
--- a/src/google/protobuf/util/internal/utility.h
+++ b/src/google/protobuf/util/internal/utility.h
@@ -39,8 +39,9 @@
#include
#include
#include
-#include
#include
+#include
+
#include
#include
@@ -187,7 +188,7 @@ PROTOBUF_EXPORT std::string FloatAsString(float value);
// Convert from int32, int64, uint32, uint64, double or float to string.
template
std::string ValueAsString(T value) {
- return SimpleItoa(value);
+ return StrCat(value);
}
template <>
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc
index d1183c0b9d..e2239fc490 100644
--- a/src/google/protobuf/util/message_differencer.cc
+++ b/src/google/protobuf/util/message_differencer.cc
@@ -1761,16 +1761,14 @@ void MessageDifferencer::StreamReporter::PrintPath(
continue;
}
} else {
- printer_->PrintRaw(
- SimpleItoa(specific_field.unknown_field_number));
+ printer_->PrintRaw(StrCat(specific_field.unknown_field_number));
}
if (left_side && specific_field.index >= 0) {
- printer_->Print("[$name$]", "name",
- SimpleItoa(specific_field.index));
+ printer_->Print("[$name$]", "name", StrCat(specific_field.index));
}
if (!left_side && specific_field.new_index >= 0) {
printer_->Print("[$name$]", "name",
- SimpleItoa(specific_field.new_index));
+ StrCat(specific_field.new_index));
}
}
}
@@ -1825,7 +1823,7 @@ StreamReporter::PrintUnknownFieldValue(const UnknownField* unknown_field) {
string output;
switch (unknown_field->type()) {
case UnknownField::TYPE_VARINT:
- output = SimpleItoa(unknown_field->varint());
+ output = StrCat(unknown_field->varint());
break;
case UnknownField::TYPE_FIXED32:
output = StrCat(
diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc
index a7cba004e3..fbcc27fb6c 100644
--- a/src/google/protobuf/util/time_util.cc
+++ b/src/google/protobuf/util/time_util.cc
@@ -38,6 +38,7 @@
#include
+
#include
namespace google {
@@ -184,7 +185,7 @@ string TimeUtil::ToString(const Duration& duration) {
seconds = -seconds;
nanos = -nanos;
}
- result += SimpleItoa(seconds);
+ result += StrCat(seconds);
if (nanos != 0) {
result += "." + FormatNanos(nanos);
}
diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc
index 4d7a3c0753..a363e18e53 100644
--- a/src/google/protobuf/util/type_resolver_util.cc
+++ b/src/google/protobuf/util/type_resolver_util.cc
@@ -315,16 +315,16 @@ class DescriptorPoolTypeResolver : public TypeResolver {
string DefaultValueAsString(const FieldDescriptor* descriptor) {
switch (descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return SimpleItoa(descriptor->default_value_int32());
+ return StrCat(descriptor->default_value_int32());
break;
case FieldDescriptor::CPPTYPE_INT64:
- return SimpleItoa(descriptor->default_value_int64());
+ return StrCat(descriptor->default_value_int64());
break;
case FieldDescriptor::CPPTYPE_UINT32:
- return SimpleItoa(descriptor->default_value_uint32());
+ return StrCat(descriptor->default_value_uint32());
break;
case FieldDescriptor::CPPTYPE_UINT64:
- return SimpleItoa(descriptor->default_value_uint64());
+ return StrCat(descriptor->default_value_uint64());
break;
case FieldDescriptor::CPPTYPE_FLOAT:
return SimpleFtoa(descriptor->default_value_float());
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
index ed1410ebd3..0f1a03bc39 100644
--- a/src/google/protobuf/wire_format_lite.h
+++ b/src/google/protobuf/wire_format_lite.h
@@ -912,6 +912,29 @@ inline size_t ComputeUnknownMessageSetItemsSize(const std::string& unknown_field
return unknown_fields.size();
}
+// Some convenience functions to simplify the generated parse loop code.
+// Returning the value and updating the buffer pointer allows for nicer
+// function composition. We rely on the compiler to inline this.
+// Also in debug compiles having local scoped variables tend to generated
+// stack frames that scale as O(num fields).
+inline uint64 ReadVarint(const char** p) {
+ uint64 tmp;
+ *p = io::Parse64(*p, &tmp);
+ return tmp;
+}
+
+inline int64 ReadVarintZigZag64(const char** p) {
+ uint64 tmp;
+ *p = io::Parse64(*p, &tmp);
+ return WireFormatLite::ZigZagDecode64(tmp);
+}
+
+inline int32 ReadVarintZigZag32(const char** p) {
+ uint64 tmp;
+ *p = io::Parse64(*p, &tmp);
+ return WireFormatLite::ZigZagDecode32(tmp);
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc
index 202c9f3ddc..12fd3179c7 100644
--- a/src/google/protobuf/wrappers.pb.cc
+++ b/src/google/protobuf/wrappers.pb.cc
@@ -402,10 +402,8 @@ const char* DoubleValue::_InternalParse(const char* begin, const char* end, void
// double value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 9) goto handle_unusual;
- double val;
- ::std::memcpy(&val, ptr, 8);
- ptr += 8;
- msg->set_value(val);
+ msg->set_value(::google::protobuf::io::UnalignedLoad(ptr));
+ ptr += sizeof(double);
break;
}
default: {
@@ -691,10 +689,8 @@ const char* FloatValue::_InternalParse(const char* begin, const char* end, void*
// float value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 13) goto handle_unusual;
- float val;
- std::memcpy(&val, ptr, 4);
- ptr += 4;
- msg->set_value(val);
+ msg->set_value(::google::protobuf::io::UnalignedLoad(ptr));
+ ptr += sizeof(float);
break;
}
default: {
@@ -980,11 +976,8 @@ const char* Int64Value::_InternalParse(const char* begin, const char* end, void*
// int64 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int64 value = val;
- msg->set_value(value);
break;
}
default: {
@@ -1272,11 +1265,8 @@ const char* UInt64Value::_InternalParse(const char* begin, const char* end, void
// uint64 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::uint64 value = val;
- msg->set_value(value);
break;
}
default: {
@@ -1564,11 +1554,8 @@ const char* Int32Value::_InternalParse(const char* begin, const char* end, void*
// int32 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::int32 value = val;
- msg->set_value(value);
break;
}
default: {
@@ -1856,11 +1843,8 @@ const char* UInt32Value::_InternalParse(const char* begin, const char* end, void
// uint32 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- ::google::protobuf::uint32 value = val;
- msg->set_value(value);
break;
}
default: {
@@ -2148,11 +2132,8 @@ const char* BoolValue::_InternalParse(const char* begin, const char* end, void*
// bool value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
- ::google::protobuf::uint64 val;
- ptr = ::google::protobuf::io::Parse64(ptr, &val);
+ msg->set_value(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- bool value = val;
- msg->set_value(value);
break;
}
default: {
@@ -2448,16 +2429,13 @@ const char* StringValue::_InternalParse(const char* begin, const char* end, void
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.StringValue.value");
- auto str = msg->mutable_value();
+ object = msg->mutable_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -2476,6 +2454,10 @@ const char* StringValue::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2772,16 +2754,13 @@ const char* BytesValue::_InternalParse(const char* begin, const char* end, void*
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- auto str = msg->mutable_value();
+ object = msg->mutable_value();
if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
- object = str;
- str->clear();
- str->reserve(size);
parser_till_end = ::google::protobuf::internal::GreedyStringParser;
- goto len_delim_till_end;
+ goto string_till_end;
}
GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheck(ptr, size, ctx));
- ::google::protobuf::internal::InlineGreedyStringParser(str, ptr, size, ctx);
+ ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
ptr += size;
break;
}
@@ -2800,6 +2779,10 @@ const char* BytesValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
+string_till_end:
+ static_cast<::std::string*>(object)->clear();
+ static_cast<::std::string*>(object)->reserve(size);
+ goto len_delim_till_end;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);