Revert "put buffer into client session as allocation optimization"

This reverts commit 09b601528b.
pull/1269/head
Darien Raymond 2018-09-14 16:51:12 +02:00
parent eeca745e89
commit 2ad12084ba
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 2 additions and 5 deletions

View File

@ -37,8 +37,6 @@ type ClientSession struct {
responseBodyIV [16]byte responseBodyIV [16]byte
responseReader io.Reader responseReader io.Reader
responseHeader byte responseHeader byte
buffer [33]byte // 16 + 16 + 1
} }
var clientSessionPool = sync.Pool{ var clientSessionPool = sync.Pool{
@ -47,11 +45,10 @@ var clientSessionPool = sync.Pool{
// NewClientSession creates a new ClientSession. // NewClientSession creates a new ClientSession.
func NewClientSession(idHash protocol.IDHash) *ClientSession { func NewClientSession(idHash protocol.IDHash) *ClientSession {
session := clientSessionPool.Get().(*ClientSession) randomBytes := make([]byte, 33) // 16 + 16 + 1
randomBytes := session.buffer[:]
common.Must2(rand.Read(randomBytes)) common.Must2(rand.Read(randomBytes))
session := clientSessionPool.Get().(*ClientSession)
copy(session.requestBodyKey[:], randomBytes[:16]) copy(session.requestBodyKey[:], randomBytes[:16])
copy(session.requestBodyIV[:], randomBytes[16:32]) copy(session.requestBodyIV[:], randomBytes[16:32])
session.responseHeader = randomBytes[32] session.responseHeader = randomBytes[32]