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
663be66f
Commit
663be66f
authored
Aug 01, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: slightly reduce memory usage when walking large directory trees
parent
2442feaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
merkledag.go
merkledag.go
+9
-9
No files found.
merkledag.go
View file @
663be66f
...
@@ -462,8 +462,8 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
...
@@ -462,8 +462,8 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
depth
int
depth
int
}
}
feed
:=
make
(
chan
*
cidDepth
)
feed
:=
make
(
chan
cidDepth
)
out
:=
make
(
chan
*
linksDepth
)
out
:=
make
(
chan
linksDepth
)
done
:=
make
(
chan
struct
{})
done
:=
make
(
chan
struct
{})
var
visitlk
sync
.
Mutex
var
visitlk
sync
.
Mutex
...
@@ -505,7 +505,7 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
...
@@ -505,7 +505,7 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
return
return
}
}
outLinks
:=
&
linksDepth
{
outLinks
:=
linksDepth
{
links
:
links
,
links
:
links
,
depth
:
depth
+
1
,
depth
:
depth
+
1
,
}
}
...
@@ -526,10 +526,10 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
...
@@ -526,10 +526,10 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
defer
close
(
feed
)
defer
close
(
feed
)
send
:=
feed
send
:=
feed
var
todoQueue
[]
*
cidDepth
var
todoQueue
[]
cidDepth
var
inProgress
int
var
inProgress
int
next
:=
&
cidDepth
{
next
:=
cidDepth
{
cid
:
root
,
cid
:
root
,
depth
:
0
,
depth
:
0
,
}
}
...
@@ -542,22 +542,22 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
...
@@ -542,22 +542,22 @@ func parallelWalkDepth(ctx context.Context, getLinks GetLinks, root cid.Cid, vis
next
=
todoQueue
[
0
]
next
=
todoQueue
[
0
]
todoQueue
=
todoQueue
[
1
:
]
todoQueue
=
todoQueue
[
1
:
]
}
else
{
}
else
{
next
=
nil
next
=
cidDepth
{}
send
=
nil
send
=
nil
}
}
case
<-
done
:
case
<-
done
:
inProgress
--
inProgress
--
if
inProgress
==
0
&&
next
==
nil
{
if
inProgress
==
0
&&
!
next
.
cid
.
Defined
()
{
return
nil
return
nil
}
}
case
linksDepth
:=
<-
out
:
case
linksDepth
:=
<-
out
:
for
_
,
lnk
:=
range
linksDepth
.
links
{
for
_
,
lnk
:=
range
linksDepth
.
links
{
cd
:=
&
cidDepth
{
cd
:=
cidDepth
{
cid
:
lnk
.
Cid
,
cid
:
lnk
.
Cid
,
depth
:
linksDepth
.
depth
,
depth
:
linksDepth
.
depth
,
}
}
if
next
==
nil
{
if
!
next
.
cid
.
Defined
()
{
next
=
cd
next
=
cd
send
=
feed
send
=
feed
}
else
{
}
else
{
...
...
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