Commit 3b80bf49 authored by Steven Allen's avatar Steven Allen

bitswap: better wantmanager allocation patterns

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent bf9f36e3
...@@ -94,7 +94,7 @@ type wantSet struct { ...@@ -94,7 +94,7 @@ type wantSet struct {
} }
func (pm *WantManager) addEntries(ctx context.Context, ks []*cid.Cid, targets []peer.ID, cancel bool, ses uint64) { func (pm *WantManager) addEntries(ctx context.Context, ks []*cid.Cid, targets []peer.ID, cancel bool, ses uint64) {
var entries []*bsmsg.Entry entries := make([]*bsmsg.Entry, 0, len(ks))
for i, k := range ks { for i, k := range ks {
entries = append(entries, &bsmsg.Entry{ entries = append(entries, &bsmsg.Entry{
Cancel: cancel, Cancel: cancel,
...@@ -340,7 +340,7 @@ func (pm *WantManager) Run() { ...@@ -340,7 +340,7 @@ func (pm *WantManager) Run() {
pm.stopPeerHandler(p.peer) pm.stopPeerHandler(p.peer)
} }
case req := <-pm.peerReqs: case req := <-pm.peerReqs:
var peers []peer.ID peers := make([]peer.ID, 0, len(pm.peers))
for p := range pm.peers { for p := range pm.peers {
peers = append(peers, p) peers = append(peers, p)
} }
......
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