Add debugging counters to `GetClassData()`
This change is aimed to help the ongoing optimization efforts around the use of `ClassData`.
PiperOrigin-RevId: 811554065
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
index 8bec7c6..a568dd6 100644
--- a/src/google/protobuf/message_lite.h
+++ b/src/google/protobuf/message_lite.h
@@ -1219,8 +1219,10 @@
PROTOBUF_NDEBUG_INLINE const ClassData* GetClassData(const T& msg) {
static_assert(std::is_base_of_v<MessageLite, T>);
if constexpr (std::is_same_v<T, MessageLite> || std::is_same_v<Message, T>) {
+ PROTOBUF_DEBUG_COUNTER("GetClassData.Virtual").Inc();
return msg.GetClassData();
} else {
+ PROTOBUF_DEBUG_COUNTER("GetClassData.Constexpr").Inc();
return MessageTraits<T>::class_data();
}
}