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

improve Notification.ToBinary() to reduce memory copy #67

Open
longjiangyuan opened this issue Feb 2, 2016 · 1 comment
Open

improve Notification.ToBinary() to reduce memory copy #67

longjiangyuan opened this issue Feb 2, 2016 · 1 comment

Comments

@longjiangyuan
Copy link

var placeholder = [5]byte{}

func (n Notification) ToBinary() ([]byte, error) {
   ....
   /* write header place holder*/
   buf.Write(placeholder[:])

   /* write fields: token,payload... etc */
   ...

   /* rewrite header */
   b = buf.Bytes()
   b[0] = commandID
   binary.BigEndian.PutUint32(b[1:5], uint32(len(b)-5))
   return b, nil
}
@nathany
Copy link
Contributor

nathany commented Feb 3, 2016

If you want to do a pull request I can merge it, but I'm no longer helping with the maintenance of this project. There is a new HTTP/2 Notification API and a library I'm writing for that.

https://github.com/RobotsAndPencils/buford

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

No branches or pull requests

2 participants