[ https://issues.apache.org/jira/browse/THRIFT-3467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15227394#comment-15227394 ]
artem antonenko commented on THRIFT-3467: ----------------------------------------- Looks like I didn't thought that through. Now when I think about it. Although in may look like more idiomatic to use struct{} it does complicate things. For example, when you want to test whether a value is present. With bools you would do if set[key] {/*do stuff*/} That's because Go will return zero value if the key is not present which is "false". That's why we insert "true" values. With struct{} you would need to do if _, ok = set[key]; ok {/*do stuff*/} Bools are nicer, struct{} saves memory. I did simple benchmarks just to see if it does something and there're gains but not by much. So now I'm not so sure about this one. Don't know if it worth hurting readability just to save some memory. > Go Maps for Thrift Sets Should Have Values of Type struct{} > ------------------------------------------------------------ > > Key: THRIFT-3467 > URL: https://issues.apache.org/jira/browse/THRIFT-3467 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler > Affects Versions: 0.9.3 > Reporter: Tom Deering > Assignee: artem antonenko > Labels: golang > > Sets in Thrift are currently turned into maps with boolean values in Go. > Example: > Thrift > {code} > namespace go bug > service FooService{ > void bar (1:set<string> foos) > } > {code} > Go > {code} > func (p *FooServiceClient) Bar(foos map[string]bool) (err error) > {code} > Boolean map values waste memory. Map values should be of the zero-byte > struct{} type. -- This message was sent by Atlassian JIRA (v6.3.4#6332)