container/list: remove unnecessary code
Remove a unnecessary statement in the test function, the variables
aren't checked afterwards. Also remove return statements in helper
functions and remove the declaration that a the helper function return a
value. The return value isn't used in the current state of code
Change-Id: I5bc384104c1002c4138e0894938778ae9710ce4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/358714
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
diff --git a/src/container/list/list.go b/src/container/list/list.go
index 210424c..aa89b7f 100644
--- a/src/container/list/list.go
+++ b/src/container/list/list.go
@@ -104,21 +104,20 @@
return l.insert(&Element{Value: v}, at)
}
-// remove removes e from its list, decrements l.len, and returns e.
-func (l *List) remove(e *Element) *Element {
+// remove removes e from its list, decrements l.len
+func (l *List) remove(e *Element) {
e.prev.next = e.next
e.next.prev = e.prev
e.next = nil // avoid memory leaks
e.prev = nil // avoid memory leaks
e.list = nil
l.len--
- return e
}
-// move moves e to next to at and returns e.
-func (l *List) move(e, at *Element) *Element {
+// move moves e to next to at.
+func (l *List) move(e, at *Element) {
if e == at {
- return e
+ return
}
e.prev.next = e.next
e.next.prev = e.prev
@@ -127,8 +126,6 @@
e.next = at.next
e.prev.next = e
e.next.prev = e
-
- return e
}
// Remove removes e from l if e is an element of list l.
diff --git a/src/container/list/list_test.go b/src/container/list/list_test.go
index 99e006f..c74724b 100644
--- a/src/container/list/list_test.go
+++ b/src/container/list/list_test.go
@@ -283,7 +283,6 @@
l.MoveAfter(e2, e3)
checkListPointers(t, l, []*Element{e1, e3, e2, e4})
- e2, e3 = e3, e2
}
// Test PushFront, PushBack, PushFrontList, PushBackList with uninitialized List