p2p/enr: reduce allocation in Record.encode (#24034)

This commit is contained in:
Evolution404 2021-12-02 17:55:01 +08:00 committed by GitHub
parent 721c5723c0
commit 8fbe0b9b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -304,7 +304,7 @@ func (r *Record) AppendElements(list []interface{}) []interface{} {
}
func (r *Record) encode(sig []byte) (raw []byte, err error) {
list := make([]interface{}, 1, 2*len(r.pairs)+1)
list := make([]interface{}, 1, 2*len(r.pairs)+2)
list[0] = sig
list = r.AppendElements(list)
if raw, err = rlp.EncodeToBytes(list); err != nil {