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>
This commit is contained in:
Gusted 2021-10-26 01:45:44 +02:00 committed by Ian Lance Taylor
parent e9eb66da30
commit b36b001ff1
2 changed files with 5 additions and 9 deletions

View File

@ -104,21 +104,20 @@ func (l *List) insertValue(v interface{}, at *Element) *Element {
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 @@ func (l *List) move(e, at *Element) *Element {
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.

View File

@ -283,7 +283,6 @@ func TestMove(t *testing.T) {
l.MoveAfter(e2, e3)
checkListPointers(t, l, []*Element{e1, e3, e2, e4})
e2, e3 = e3, e2
}
// Test PushFront, PushBack, PushFrontList, PushBackList with uninitialized List