Skip to content

Commit

Permalink
Drop generating "compat setter pointer" for optional list thrift fields
Browse files Browse the repository at this point in the history
Summary:
To improve code generation and get rid of the legacy

#build_rule_type[go_library,go_binary]

Reviewed By: echistyakov

Differential Revision: D68407034

fbshipit-source-id: 89df118bbe590ee11a5576687cd26c2215fb132e
  • Loading branch information
inesusvet authored and facebook-github-bot committed Jan 21, 2025
1 parent 6347ee8 commit 84d64cc
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions thrift/compiler/generate/t_mstch_go_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,18 @@ class mstch_go_field : public mstch_field {
}
mstch::node is_compat_setter_pointer() { return is_compat_setter_pointer_(); }
mstch::node compat_setter_value_op() {
if (is_pointer_() && is_compat_setter_pointer_()) {
return std::string("");
} else if (is_pointer_() && !is_compat_setter_pointer_()) {
return std::string("&");
} else if (!is_pointer_() && !is_compat_setter_pointer_()) {
return std::string("");
} else { // if (!is_pointer_() && is_compat_setter_pointer_())
return std::string("*");
if (is_pointer_()) {
if (is_compat_setter_pointer_()) {
return std::string("");
} else {
return std::string("&");
}
} else { // !is_pointer_()
if (is_compat_setter_pointer_()) {
return std::string("*");
} else {
return std::string("");
}
}
}
mstch::node key_str() {
Expand Down Expand Up @@ -434,8 +438,7 @@ class mstch_go_field : public mstch_field {
bool has_default_value = (field_->default_value() != nullptr);
if (is_optional_() && has_default_value) {
auto real_type = field_->type()->get_true_type();
bool is_container =
(real_type->is_list() || real_type->is_map() || real_type->is_set());
bool is_container = (real_type->is_map() || real_type->is_set());
return is_container;
}
return is_pointer_();
Expand Down

0 comments on commit 84d64cc

Please sign in to comment.