Use ReadVarint32 for Int32 types (#8769)

* Add INT32 to list of 32-bit varint types

* update descriptor protos

Co-authored-by: Greg Stoll <greg@gregstoll.com>
pull/8955/head
Kevin Gibson 3 years ago committed by GitHub
parent a8b73fb904
commit 10d0faef6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
  2. 6
      src/google/protobuf/compiler/plugin.pb.cc
  3. 32
      src/google/protobuf/descriptor.pb.cc
  4. 2
      src/google/protobuf/duration.pb.cc
  5. 2
      src/google/protobuf/timestamp.pb.cc
  6. 6
      src/google/protobuf/type.pb.cc
  7. 2
      src/google/protobuf/wrappers.pb.cc

@ -859,7 +859,8 @@ void ParseFunctionGenerator::GenerateFieldBody(
field->number());
}
} else {
std::string size = (field->type() == FieldDescriptor::TYPE_SINT32 ||
std::string size = (field->type() == FieldDescriptor::TYPE_INT32 ||
field->type() == FieldDescriptor::TYPE_SINT32 ||
field->type() == FieldDescriptor::TYPE_UINT32)
? "32"
: "64";

@ -318,7 +318,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
_Internal::set_has_major(&has_bits);
major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -327,7 +327,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_minor(&has_bits);
minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -336,7 +336,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
_Internal::set_has_patch(&has_bits);
patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

@ -1727,7 +1727,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
ptr -= 1;
do {
ptr += 1;
_internal_add_public_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
_internal_add_public_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<80>(ptr));
@ -1743,7 +1743,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME
ptr -= 1;
do {
ptr += 1;
_internal_add_weak_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
_internal_add_weak_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<88>(ptr));
@ -2219,7 +2219,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -2228,7 +2228,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -2485,7 +2485,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -2494,7 +2494,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -3599,7 +3599,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
_Internal::set_has_number(&has_bits);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -3666,7 +3666,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM
case 9:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
_Internal::set_has_oneof_index(&has_bits);
oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -4385,7 +4385,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -4394,7 +4394,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -5034,7 +5034,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_number(&has_bits);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -9833,7 +9833,7 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_path(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8) {
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
} else
goto handle_unusual;
@ -9844,7 +9844,7 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_span(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16) {
_internal_add_span(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
_internal_add_span(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
} else
goto handle_unusual;
@ -10405,7 +10405,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_path(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8) {
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
} else
goto handle_unusual;
@ -10426,7 +10426,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
_Internal::set_has_begin(&has_bits);
begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -10435,7 +10435,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
_Internal::set_has_end(&has_bits);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

@ -157,7 +157,7 @@ const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i
// int32 nanos = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

@ -157,7 +157,7 @@ const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::
// int32 nanos = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

@ -847,7 +847,7 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
// int32 number = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -875,7 +875,7 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
// int32 oneof_index = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@ -1646,7 +1646,7 @@ const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::
// int32 number = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

@ -1026,7 +1026,7 @@ const char* Int32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:
// int32 value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;

Loading…
Cancel
Save