Commit 6362ccb0 authored by Steven Allen's avatar Steven Allen

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.
parent 6addc7f5
...@@ -78,7 +78,7 @@ func (m *multiaddr) Protocols() []Protocol { ...@@ -78,7 +78,7 @@ func (m *multiaddr) Protocols() []Protocol {
} }
}() }()
var ps []Protocol ps := make([]Protocol, 0, 8)
b := m.bytes b := m.bytes
for len(b) > 0 { for len(b) > 0 {
code, n, err := ReadVarintCode(b) code, n, err := ReadVarintCode(b)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment