Skip to content

Commit

Permalink
Use ARM-optimized varint decoding functions with table-driven parser.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 488411424
  • Loading branch information
protobuf-github-bot authored and Copybara-Service committed Nov 14, 2022
1 parent 7140f6f commit 0e7d311
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/google/protobuf/generated_message_tctable_lite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,20 @@ Parse64FallbackPair(const char* p, int64_t res1) {
return {p + 10, res1 & res2 & res3};
}

template <class Type>
template <typename Type>
inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p,
Type* value) {
static_assert(sizeof(Type) == 4 || sizeof(Type) == 8,
"Only [u]int32_t and [u]int64_t please");
#ifdef __aarch64__
// The VarintParse parser has a faster implementation on ARM.
absl::conditional_t<sizeof(Type) == 4, uint32_t, uint64_t> tmp;
p = VarintParse(p, &tmp);
if (p != nullptr) {
*value = tmp;
}
return p;
#endif
int64_t byte = static_cast<int8_t>(*p);
if (PROTOBUF_PREDICT_TRUE(byte >= 0)) {
*value = byte;
Expand Down

0 comments on commit 0e7d311

Please sign in to comment.