Commit 94458b3b authored by Shenghou Ma's avatar Shenghou Ma

go.net/websocket: optimize frame masking code

From Jens.Alfke@gmail.com.
Fixes golang/go#5269.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8748050
parent 68e1a212
......@@ -216,10 +216,9 @@ func (frame *hybiFrameWriter) Write(msg []byte) (n int, err error) {
}
header = append(header, frame.header.MaskingKey...)
frame.writer.Write(header)
var data []byte
for i := 0; i < length; i++ {
data = append(data, msg[i]^frame.header.MaskingKey[i%4])
data := make([]byte, length)
for i := range data {
data[i] = msg[i] ^ frame.header.MaskingKey[i%4]
}
frame.writer.Write(data)
err = frame.writer.Flush()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment