]> Cypherpunks repositories - gostls13.git/commitdiff
container/list: remove unnecessary code
authorGusted <williamzijl7@hotmail.com>
Mon, 25 Oct 2021 23:45:44 +0000 (01:45 +0200)
committerIan Lance Taylor <iant@golang.org>
Tue, 26 Oct 2021 00:30:24 +0000 (00:30 +0000)
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>

src/container/list/list.go
src/container/list/list_test.go

index 210424ceed7b7cac8bb793f9614845aa3ecc2080..aa89b7f599d9f0b75222bf9e327083e2fce27aa1 100644 (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.
index 99e006f39fdafddc07ba9ffd506dfbf920abe516..c74724b3985a67ca4f341f8b06d02e33ae37f08b 100644 (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