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

sync to yalanting libs #289

Merged
merged 3 commits into from
Jun 27, 2024
Merged

Conversation

171930433
Copy link
Contributor

No description provided.

Comment on lines 116 to 129
std::vector<std::string_view> get_fields_name() const override {
static constexpr auto map = iguana::get_members<T>();

std::vector<std::string_view> vec;
for (auto [no, val] : map) {
std::set<std::string_view> sets;

for (auto const& [no, val] : map) {
std::visit(
[&](auto& field) {
vec.push_back(std::string_view(field.field_name.data(),
field.field_name.size()));
[&](auto const& field) {
if (auto it = sets.emplace(field.field_name.data(),
field.field_name.size());
it.second) {
vec.push_back(*it.first);
}
Copy link
Collaborator

@bbbgan bbbgan Jun 25, 2024

Choose a reason for hiding this comment

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

variant造成重复应该是相邻的吧,直接判断和上一个是否一样就行了,不需要set,可以简化一下!

Copy link
Owner

Choose a reason for hiding this comment

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

有道理,确实可以简化一下。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

有道理,已修改

[&](auto const& field) {
std::string_view const current_name{field.field_name.data(),
field.field_name.size()};
if (vec.empty() || (!vec.empty() && (vec.back() != current_name))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里可以稍微简化一下,

if (vec.empty() || (vec.back() != current_name))

因为判断vec.back()的时候前面的vec.empty()一定是false,否则为true不会执行vec.back()

@qicosmos qicosmos merged commit e27f437 into qicosmos:master Jun 27, 2024
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