Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
0db465ea
Commit
0db465ea
authored
Jul 11, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nit: avoid copying CIDs
parent
5d52f027
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
merkledag.go
merkledag.go
+3
-4
No files found.
merkledag.go
View file @
0db465ea
...
...
@@ -172,7 +172,7 @@ func FetchGraphWithDepthLimit(ctx context.Context, root cid.Cid, depthLim int, s
ng
=
&
sesGetter
{
bserv
.
NewSession
(
ctx
,
ds
.
Blocks
)}
}
set
:=
make
(
map
[
string
]
int
)
set
:=
make
(
map
[
cid
.
Cid
]
int
)
// Visit function returns true when:
// * 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
// depthLim = -1 means we only return true if the element is not in the
// set.
visit
:=
func
(
c
cid
.
Cid
,
depth
int
)
bool
{
key
:=
string
(
c
.
Bytes
())
oldDepth
,
ok
:=
set
[
key
]
oldDepth
,
ok
:=
set
[
c
]
if
(
ok
&&
depthLim
<
0
)
||
(
depthLim
>=
0
&&
depth
>
depthLim
)
{
return
false
}
if
!
ok
||
oldDepth
>
depth
{
set
[
key
]
=
depth
set
[
c
]
=
depth
return
true
}
return
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment