From: Joe Kyo Date: Wed, 13 Nov 2019 06:47:41 +0000 (-0600) Subject: container/list: remove temporary variable `n` X-Git-Tag: go1.15beta1~1155 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2edeb23bf5c547078392f1aaedc1a3840c72e3d8;p=gostls13.git 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 --- diff --git a/src/container/list/list.go b/src/container/list/list.go index b8b599aabb..cc9ff0988c 100644 --- a/src/container/list/list.go +++ b/src/container/list/list.go @@ -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 }