Commit 0db465ea authored by Steven Allen's avatar Steven Allen

nit: avoid copying CIDs

parent 5d52f027
...@@ -172,7 +172,7 @@ func FetchGraphWithDepthLimit(ctx context.Context, root cid.Cid, depthLim int, s ...@@ -172,7 +172,7 @@ func FetchGraphWithDepthLimit(ctx context.Context, root cid.Cid, depthLim int, s
ng = &sesGetter{bserv.NewSession(ctx, ds.Blocks)} ng = &sesGetter{bserv.NewSession(ctx, ds.Blocks)}
} }
set := make(map[string]int) set := make(map[cid.Cid]int)
// Visit function returns true when: // Visit function returns true when:
// * The element is not in the set and we're not over depthLim // * The element is not in the set and we're not over depthLim
...@@ -182,15 +182,14 @@ func FetchGraphWithDepthLimit(ctx context.Context, root cid.Cid, depthLim int, s ...@@ -182,15 +182,14 @@ func FetchGraphWithDepthLimit(ctx context.Context, root cid.Cid, depthLim int, s
// depthLim = -1 means we only return true if the element is not in the // depthLim = -1 means we only return true if the element is not in the
// set. // set.
visit := func(c cid.Cid, depth int) bool { visit := func(c cid.Cid, depth int) bool {
key := string(c.Bytes()) oldDepth, ok := set[c]
oldDepth, ok := set[key]
if (ok && depthLim < 0) || (depthLim >= 0 && depth > depthLim) { if (ok && depthLim < 0) || (depthLim >= 0 && depth > depthLim) {
return false return false
} }
if !ok || oldDepth > depth { if !ok || oldDepth > depth {
set[key] = depth set[c] = depth
return true return true
} }
return false return false
......
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