fewer allocations on unpin
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Dec 3, 2017 at 19:05 UTC
9a335cee133391f211e8b4433bb965d802abcb04
1 file changed
+3
-3
core/corerepo/pinning.go
+3
-3
@@ -58,14 +58,14 @@ func Pin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool)
58
}
59
60
func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool) ([]*cid.Cid, error) {
61
- var unpinned []*cid.Cid
61
+ unpinned := make([]*cid.Cid, len(paths))
62
63
r := &path.Resolver{
64
DAG: n.DAG,
65
ResolveOnce: uio.ResolveUnixfsOnce,
66
}
67
68
- for _, p := range paths {
68
+ for i, p := range paths {
69
p, err := path.ParsePath(p)
70
if err != nil {
71
return nil, err
@@ -80,7 +80,7 @@ func Unpin(n *core.IpfsNode, ctx context.Context, paths []string, recursive bool
80
if err != nil {
81
return nil, err
82
}
83
- unpinned = append(unpinned, k)
83
+ unpinned[i] = k
84
}
85
86
err := n.Pinning.Flush()