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
fc8b2d42
Commit
fc8b2d42
authored
Aug 28, 2018
by
dignifiedquire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: avoid allocations when filtering nodes
parent
2d4e804f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
node.go
node.go
+10
-6
No files found.
node.go
View file @
fc8b2d42
...
...
@@ -126,22 +126,26 @@ func (n *ProtoNode) AddRawLink(name string, l *ipld.Link) error {
// RemoveNodeLink removes a link on this node by the given name.
func
(
n
*
ProtoNode
)
RemoveNodeLink
(
name
string
)
error
{
n
.
encoded
=
nil
good
:=
make
([]
*
ipld
.
Link
,
0
,
len
(
n
.
links
))
var
found
bool
for
_
,
l
:=
range
n
.
links
{
if
l
.
Name
!=
name
{
good
=
append
(
good
,
l
)
ref
:=
&
n
.
links
filterPos
:=
0
found
:=
false
for
i
:=
0
;
i
<
len
(
*
ref
);
i
++
{
if
v
:=
(
*
ref
)[
i
];
v
.
Name
!=
name
{
(
*
ref
)[
filterPos
]
=
v
filterPos
++
}
else
{
found
=
true
}
}
n
.
links
=
good
if
!
found
{
return
ipld
.
ErrNotFound
}
n
.
links
=
(
*
ref
)[
:
filterPos
]
return
nil
}
...
...
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