-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve [struct_pb] #257
improve [struct_pb] #257
Conversation
iguana/struct_pb.hpp
Outdated
@@ -221,10 +223,10 @@ inline void from_pb_impl(T& val, std::string_view& pb_str, uint32_t field_no) { | |||
if constexpr (is_reflection_v<value_type>) { | |||
size_t pos; | |||
uint32_t size = detail::decode_varint(pb_str, pos); | |||
pb_str = pb_str.substr(pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bug,应该先移动再判断,判断剩余的字符串的大小和size之间的关系。剩下有几处也类似
iguana/struct_pb.hpp
Outdated
} | ||
else { | ||
detail::encode_fixed_field(field_no, WireType::Fixed32, (uint32_t)(val), | ||
out); | ||
detail::encode_fixed_field(field_no, WireType::Fixed32, val, out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该不需要强制转换吧,在处理double类型会出现问题,我认为没有强制转换的必要,所以我删除了。
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## struct_pb #257 +/- ##
=============================================
+ Coverage 45.08% 48.37% +3.29%
=============================================
Files 46 51 +5
Lines 5638 6135 +497
=============================================
+ Hits 2542 2968 +426
- Misses 3096 3167 +71 ☔ View full report in Codecov by Sentry. |
b237bfb
to
6c2a2e4
Compare
iguana/reflection.hpp
Outdated
get_members_impl(t), 1, std::make_index_sequence<Size>{}); | ||
return map; | ||
using Tuple = decltype(reflect_members::apply_impl()); | ||
constexpr size_t TypeSize = tuple_type_count<Tuple>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuple_type_count 这个方法是多余的。有两种方法获取tuple的size,第一种:
constexpr size_t Size = reflect_members::value();
第二种:
std::tuple_size_v<Tuple>
iguana/reflection.hpp
Outdated
constexpr auto offset_arr = get_offset_arr<sizeof...(I), T>(); | ||
constexpr auto remap_arr = get_remap_arr(offset_arr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥需要这两个arr呢?
iguana/reflection.hpp
Outdated
constexpr auto type_options_arr = | ||
get_type_options_arr<Tuple>(std::make_index_sequence<Size>{}); | ||
return get_field_tuple_impl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉这些代码似乎可以简化。
No description provided.