1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

remove unnecessary memory allocation in id generation

This commit is contained in:
v2ray 2016-01-12 13:39:02 +01:00
parent 1958a874cd
commit f7a152b871

View File

@ -33,18 +33,15 @@ func (this *ID) UUID() *uuid.UUID {
return this.uuid
}
func NewID(uuid *uuid.UUID) *ID {
md5hash := md5.New()
md5hash.Write(uuid.Bytes())
md5hash.Write([]byte("c48619fe-8f02-49e0-b9e9-edf763e17e21"))
cmdKey := md5.Sum(nil)
return &ID{
uuid: uuid,
cmdKey: cmdKey,
}
}
func (v ID) CmdKey() []byte {
return v.cmdKey[:]
}
func NewID(uuid *uuid.UUID) *ID {
id := &ID{uuid: uuid}
md5hash := md5.New()
md5hash.Write(uuid.Bytes())
md5hash.Write([]byte("c48619fe-8f02-49e0-b9e9-edf763e17e21"))
md5.Sum(id.cmdKey[:0])
return id
}