-
Notifications
You must be signed in to change notification settings - Fork 380
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
Manually marshal packets for more speed #18
Conversation
Looks good except for one problem, types_like_this_are_not_considered_idiomatic, please use sftpSomethingSomethingSomething. |
Reworked initial commit for CamelCase over underscore_case and added a |
func sendPacket(w io.Writer, m encoding.BinaryMarshaler) error { | ||
bb, err := m.MarshalBinary() | ||
if err != nil { | ||
return errors.New(fmt.Sprintf("marshal2(%#v): binary marshaller failed", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf(...)
LGTM. Just one little nit then I can merge this. Thank you for this, it will help #15 a lot. |
Wow, didn't know about |
Manually marshal packets for more speed
Lovely. Thanks a lot. |
We change the
sendPacket
function to accept aencoding.BinaryMashaler
and implement the relatedMarshalBinary
function on each packet type. This gives us great speed and allocation wins (see #16) at the expense of less readability, albeit one-time only.