From 9a335cee133391f211e8b4433bb965d802abcb04 Mon Sep 17 00:00:00 2001
From: Steven Allen <steven@stebalien.com>
Date: Sun, 3 Dec 2017 19:05:05 -0800
Subject: [PATCH] fewer allocations on unpin

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
---
 core/corerepo/pinning.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/corerepo/pinning.go b/core/corerepo/pinning.go
index e49eb210a..f00fa2392 100644
--- a/core/corerepo/pinning.go
+++ b/core/corerepo/pinning.go
@@ -58,14 +58,14 @@ func Pin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool)
 }
 
 func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool) ([]*cid.Cid, error) {
-	var unpinned []*cid.Cid
+	unpinned := make([]*cid.Cid, len(paths))
 
 	r := &path.Resolver{
 		DAG:         n.DAG,
 		ResolveOnce: uio.ResolveUnixfsOnce,
 	}
 
-	for _, p := range paths {
+	for i, p := range paths {
 		p, err := path.ParsePath(p)
 		if err != nil {
 			return nil, err
@@ -80,7 +80,7 @@ func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool
 		if err != nil {
 			return nil, err
 		}
-		unpinned = append(unpinned, k)
+		unpinned[i] = k
 	}
 
 	err := n.Pinning.Flush()
-- 
GitLab