diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index e146aefe42a8..2cbd2a36e2e8 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -789,11 +789,20 @@ Parse64FallbackPair(const char* p, int64_t res1) { return {p + 10, res1 & res2 & res3}; } -template +template 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 tmp; + p = VarintParse(p, &tmp); + if (p != nullptr) { + *value = tmp; + } + return p; +#endif int64_t byte = static_cast(*p); if (PROTOBUF_PREDICT_TRUE(byte >= 0)) { *value = byte;