Selaa lähdekoodia

remove unnecessary memory allocation in vmess

v2ray 9 vuotta sitten
vanhempi
commit
7881330644
1 muutettua tiedostoa jossa 3 lisäystä ja 1 poistoa
  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()