From 9db5b11c9cf2922435b53495b9c1e114525f0428 Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Tue, 24 Jan 2017 17:37:33 -0800 Subject: Work with truncated tag numbers. This allows more compact comparisons (1 byte instead of 4 byte immediates on x86) for each possible wire/tag inside each field. --- src/google/protobuf/wrappers.pb.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/google/protobuf/wrappers.pb.cc') diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 3b9bf7a4..0dad64a4 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -312,7 +312,8 @@ bool DoubleValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // double value = 1; case 1: { - if (tag == 9u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(9u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -567,7 +568,8 @@ bool FloatValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // float value = 1; case 1: { - if (tag == 13u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(13u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -822,7 +824,8 @@ bool Int64Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int64 value = 1; case 1: { - if (tag == 8u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -1079,7 +1082,8 @@ bool UInt64Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint64 value = 1; case 1: { - if (tag == 8u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1336,7 +1340,8 @@ bool Int32Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int32 value = 1; case 1: { - if (tag == 8u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1593,7 +1598,8 @@ bool UInt32Value::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint32 value = 1; case 1: { - if (tag == 8u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1850,7 +1856,8 @@ bool BoolValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // bool value = 1; case 1: { - if (tag == 8u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -2110,7 +2117,8 @@ bool StringValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // string value = 1; case 1: { - if (tag == 10u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2437,7 +2445,8 @@ bool BytesValue::MergePartialFromCodedStream( switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // bytes value = 1; case 1: { - if (tag == 10u) { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { -- cgit v1.2.3