From 78813306446cd20b1bb8e80607e0ec0e5090d4bf Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 12 Jan 2016 13:39:17 +0100 Subject: [PATCH] remove unnecessary memory allocation in vmess --- proxy/vmess/protocol/vmess.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/vmess/protocol/vmess.go b/proxy/vmess/protocol/vmess.go index 1a54359bf..f02a730b9 100644 --- a/proxy/vmess/protocol/vmess.go +++ b/proxy/vmess/protocol/vmess.go @@ -180,7 +180,9 @@ func (this *VMessRequest) ToBytes(timestampGenerator RandomTimestampGenerator, b idHash := IDHash(this.User.AnyValidID().Bytes()) idHash.Write(timestamp.Bytes()) - buffer.Append(idHash.Sum(nil)) + hashStart := buffer.Len() + buffer.Slice(0, hashStart+16) + idHash.Sum(buffer.Value[hashStart:hashStart]) encryptionBegin := buffer.Len()