p2p: prealloc slice

This commit is contained in:
cuiweixie 2025-07-31 19:07:47 +08:00
parent d4a3bf1b23
commit 1837af6ab9

View file

@ -561,7 +561,7 @@ type PeerInfo struct {
// Info gathers and returns a collection of metadata known about a peer.
func (p *Peer) Info() *PeerInfo {
// Gather the protocol capabilities
var caps []string
caps := make([]string, 0, len(p.Caps()))
for _, cap := range p.Caps() {
caps = append(caps, cap.String())
}