原型定义如下:
/*
Message Test {
int32 a = 1;
repeated int64 b = 2;
};
*/
c++代码如下:
// msg is a `Test` type pointer
int32_t get_a(google::protobuf::Message* msg) {
Test t1;
// what is the most efficient way to convert `msg` to `t1`
return t1.a();
}
ParseFromString据我所知,可能太慢了。反射慢吗?解决这个问题的最佳方法是什么?