Преглед изворни кода

remove unnecessary memory allocation in vmess

v2ray пре 9 година
родитељ
комит
7881330644
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      proxy/vmess/protocol/vmess.go

+ 3 - 1
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()