Remove static initializer in wire_format_lite.cc.
This commit is contained in:
parent
f5de486b53
commit
324779ad70
2 changed files with 19 additions and 4 deletions
|
@ -680,6 +680,21 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
|
|||
// If negative, 10 bytes. Otheriwse, same as VarintSize32().
|
||||
static int VarintSize32SignExtended(int32 value);
|
||||
|
||||
// Compile-time equivalent of VarintSize32().
|
||||
template <uint32 Value>
|
||||
struct StaticVarintSize32 {
|
||||
static const int value =
|
||||
(Value < (1 << 7))
|
||||
? 1
|
||||
: (Value < (1 << 14))
|
||||
? 2
|
||||
: (Value < (1 << 21))
|
||||
? 3
|
||||
: (Value < (1 << 28))
|
||||
? 4
|
||||
: 5;
|
||||
};
|
||||
|
||||
// Returns the total number of bytes written since this object was created.
|
||||
inline int ByteCount() const;
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ const int WireFormatLite::kMessageSetMessageTag;
|
|||
#endif
|
||||
|
||||
const int WireFormatLite::kMessageSetItemTagsSize =
|
||||
io::CodedOutputStream::VarintSize32(kMessageSetItemStartTag) +
|
||||
io::CodedOutputStream::VarintSize32(kMessageSetItemEndTag) +
|
||||
io::CodedOutputStream::VarintSize32(kMessageSetTypeIdTag) +
|
||||
io::CodedOutputStream::VarintSize32(kMessageSetMessageTag);
|
||||
io::CodedOutputStream::StaticVarintSize32<kMessageSetItemStartTag>::value +
|
||||
io::CodedOutputStream::StaticVarintSize32<kMessageSetItemEndTag>::value +
|
||||
io::CodedOutputStream::StaticVarintSize32<kMessageSetTypeIdTag>::value +
|
||||
io::CodedOutputStream::StaticVarintSize32<kMessageSetMessageTag>::value;
|
||||
|
||||
const WireFormatLite::CppType
|
||||
WireFormatLite::kFieldTypeToCppTypeMap[MAX_FIELD_TYPE + 1] = {
|
||||
|
|
Loading…
Add table
Reference in a new issue