mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-02 13:03:11 +00:00
preallocate protocol slice
This was showing up on CPU profiles as a significant source of repeated allocations. We don't really care about over allocation (don't keep these slices around) and should rarely have more than 8 protocols in a single address.
This commit is contained in:
parent
6addc7f583
commit
6362ccb0d2
@ -78,7 +78,7 @@ func (m *multiaddr) Protocols() []Protocol {
|
||||
}
|
||||
}()
|
||||
|
||||
var ps []Protocol
|
||||
ps := make([]Protocol, 0, 8)
|
||||
b := m.bytes
|
||||
for len(b) > 0 {
|
||||
code, n, err := ReadVarintCode(b)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user