container/list: remove temporary variable `n`

The variable `n` for saving the pointer of the next
element when insert new element into the list turns
out to be unnecessary.

Change-Id: I17b85fd8350738815c320a83945525b60c2f04c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/207037
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Joe Kyo 2019-11-13 00:47:41 -06:00 committed by Robert Griesemer
parent 7855d6835d
commit 2edeb23bf5
1 changed files with 6 additions and 8 deletions

View File

@ -90,11 +90,10 @@ func (l *List) lazyInit() {
// insert inserts e after at, increments l.len, and returns e.
func (l *List) insert(e, at *Element) *Element {
n := at.next
at.next = e
e.prev = at
e.next = n
n.prev = e
e.next = at.next
e.prev.next = e
e.next.prev = e
e.list = l
l.len++
return e
@ -124,11 +123,10 @@ func (l *List) move(e, at *Element) *Element {
e.prev.next = e.next
e.next.prev = e.prev
n := at.next
at.next = e
e.prev = at
e.next = n
n.prev = e
e.next = at.next
e.prev.next = e
e.next.prev = e
return e
}