Skip to content
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

Merged
merged 24 commits into from
May 14, 2024
Merged

improve [struct_pb] #257

merged 24 commits into from
May 14, 2024

Conversation

bbbgan
Copy link
Collaborator

@bbbgan bbbgan commented Apr 26, 2024

No description provided.

@@ -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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug,应该先移动再判断,判断剩余的字符串的大小和size之间的关系。剩下有几处也类似

}
else {
detail::encode_fixed_field(field_no, WireType::Fixed32, (uint32_t)(val),
out);
detail::encode_fixed_field(field_no, WireType::Fixed32, val, out);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该不需要强制转换吧,在处理double类型会出现问题,我认为没有强制转换的必要,所以我删除了。

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2024

Codecov Report

Attention: Patch coverage is 93.45794% with 28 lines in your changes are missing coverage. Please review.

Project coverage is 48.37%. Comparing base (ac19b58) to head (93bd07e).
Report is 38 commits behind head on struct_pb.

Files Patch % Lines
iguana/detail/pb_type.hpp 7.69% 12 Missing ⚠️
iguana/pb_reader.hpp 91.75% 8 Missing ⚠️
iguana/pb_util.hpp 96.59% 3 Missing ⚠️
iguana/pb_writer.hpp 96.05% 3 Missing ⚠️
test/test_pb.cpp 98.70% 2 Missing ⚠️

❗ 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.
📢 Have feedback on the report? Share it here.

@bbbgan bbbgan force-pushed the struct_pb branch 3 times, most recently from b237bfb to 6c2a2e4 Compare May 5, 2024 08:55
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>();
Copy link
Owner

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>

Comment on lines 838 to 839
constexpr auto offset_arr = get_offset_arr<sizeof...(I), T>();
constexpr auto remap_arr = get_remap_arr(offset_arr);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥需要这两个arr呢?

Comment on lines 793 to 795
constexpr auto type_options_arr =
get_type_options_arr<Tuple>(std::make_index_sequence<Size>{});
return get_field_tuple_impl(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉这些代码似乎可以简化。

@bbbgan bbbgan changed the title fix; support [double, float, bool] improve [struct_pb] May 10, 2024
@qicosmos qicosmos merged commit 9dd7b1a into qicosmos:struct_pb May 14, 2024
16 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants