Performance improvement, avoid create new slice for each Read

Author: ghostCreated Jan 22, 2019Updated Jan 22, 2019

https://github.com/shadowsocks/shadowsocks-go/blob/49161ddf51fc65cf557554b8909aeb82e9da5409/shadowsocks/conn.go#L109

103.60MB   103.60MB (flat, cum) 88.15% of Total
         .          .    104:           }
         .          .    105:   }
         .          .    106:
         .          .    107:   cipherData := c.readBuf
         .          .    108:   if len(b) > len(cipherData) {
  103.60MB   103.60MB    109:           cipherData = make([]byte, len(b))
         .          .    110:   } else {
         .          .    111:           cipherData = cipherData[:len(b)]
         .          .    112:   }
         .          .    113:
         .          .    114:   n, err = c.Conn.Read(cipherData)
(pprof) 

avoid create new slice for each Read().

	cipherData := c.readBuf
	if len(b) < len(cipherData) {
		cipherData = cipherData[:len(b)]
	}

Source: shadowsocks/shadowsocks-go