Skip to content

Commit

Permalink
use more idiomatic append version
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Aug 30, 2018
1 parent fc8b2d4 commit 9e4c9b9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,12 @@ func (n *ProtoNode) AddRawLink(name string, l *ipld.Link) error {
func (n *ProtoNode) RemoveNodeLink(name string) error {
n.encoded = nil

ref := &n.links
filterPos := 0
ref := n.links[:0]
found := false

for i := 0; i < len(*ref); i++ {
if v := (*ref)[i]; v.Name != name {
(*ref)[filterPos] = v
filterPos++
for _, v := range n.links {
if v.Name != name {
ref = append(ref, v)
} else {
found = true
}
Expand All @@ -144,7 +142,7 @@ func (n *ProtoNode) RemoveNodeLink(name string) error {
return ipld.ErrNotFound
}

n.links = (*ref)[:filterPos]
n.links = ref

return nil
}
Expand Down

0 comments on commit 9e4c9b9

Please sign in to comment.