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

Generate MarhsalXDR() instead of EncodeTo() #67

Closed
wants to merge 1 commit into from

Conversation

2opremio
Copy link
Contributor

xdrgen counterpart to stellar/go-xdr#17

Comment on lines -342 to +338
out.puts "func (s *#{name}) EncodeTo(e *xdr.Encoder) error {"
out.puts " var err error"
out.puts "// MarshalXDR implements xdr.Marshaler."
out.puts "func (s #{name}) MarshalXDR(e *xdr.Encoder) (int, error) {"
Copy link
Contributor Author

@2opremio 2opremio Nov 10, 2021

Choose a reason for hiding this comment

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

Unfortunately, I am forced to call by value (note the lack of *) when switching to MarshallXDR)() since, otherwise, xdr.Encoder() cannot invoke the method on unadresable values.

Calling by value, which can (and as I observed, it does) cause allocations (due to the copy variables not fitting in the stack), betraying the purpose of doing all this (which is increasing performance).

@2opremio
Copy link
Contributor Author

I'm closing this PR, due to the reasons outlined above.

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.

1 participant