aboutsummaryrefslogtreecommitdiff
path: root/src/container
diff options
context:
space:
mode:
authorJoe Kyo <xunianzu@gmail.com>2019-11-13 00:47:41 -0600
committerRobert Griesemer <gri@golang.org>2020-02-21 18:32:32 +0000
commit2edeb23bf5c547078392f1aaedc1a3840c72e3d8 (patch)
tree0f992024830be1eeb21758c172f91d8841e21738 /src/container
parent7855d6835d3a27e967a0c2d748f9f39305e7ba47 (diff)
downloadgo-2edeb23bf5c547078392f1aaedc1a3840c72e3d8.tar.gz
go-2edeb23bf5c547078392f1aaedc1a3840c72e3d8.zip
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>
Diffstat (limited to 'src/container')
-rw-r--r--src/container/list/list.go14
1 files changed, 6 insertions, 8 deletions
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
}