Skip to content

Commit

Permalink
pre-allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyschlatter committed Dec 2, 2016
1 parent 7f78c36 commit a7fd74b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vncclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (c *ClientConn) KeyEvent(keysym uint32, down bool) error {
c.send.Lock()
defer c.send.Unlock()

var buf bytes.Buffer
buf := bytes.NewBuffer(make([]byte, 0, 8))

var downFlag uint8
if down {
Expand All @@ -226,7 +226,7 @@ func (c *ClientConn) KeyEvent(keysym uint32, down bool) error {
keysym,
}
for _, val := range data {
if err := binary.Write(&buf, binary.BigEndian, val); err != nil {
if err := binary.Write(buf, binary.BigEndian, val); err != nil {
return err
}
}
Expand All @@ -249,7 +249,7 @@ func (c *ClientConn) PointerEvent(mask ButtonMask, x, y uint16) error {
c.send.Lock()
defer c.send.Unlock()

var buf bytes.Buffer
buf := bytes.NewBuffer(make([]byte, 0, 6))

data := []interface{}{
uint8(5),
Expand All @@ -259,7 +259,7 @@ func (c *ClientConn) PointerEvent(mask ButtonMask, x, y uint16) error {
}

for _, val := range data {
if err := binary.Write(&buf, binary.BigEndian, val); err != nil {
if err := binary.Write(buf, binary.BigEndian, val); err != nil {
return err
}
}
Expand Down

0 comments on commit a7fd74b

Please sign in to comment.