From 9e4c9b93701bf849f6cb947c188898267f1ee3b0 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 30 Aug 2018 12:10:34 +0200 Subject: [PATCH] use more idiomatic append version --- node.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/node.go b/node.go index c3e005d162cb..cc028537f194 100644 --- a/node.go +++ b/node.go @@ -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 } @@ -144,7 +142,7 @@ func (n *ProtoNode) RemoveNodeLink(name string) error { return ipld.ErrNotFound } - n.links = (*ref)[:filterPos] + n.links = ref return nil }