]> Cypherpunks repositories - gostls13.git/commitdiff
container/list: elide redundant tests and fix comment typo
authorAndrew Gerrand <adg@golang.org>
Mon, 25 Oct 2010 03:50:47 +0000 (14:50 +1100)
committerAndrew Gerrand <adg@golang.org>
Mon, 25 Oct 2010 03:50:47 +0000 (14:50 +1100)
R=dsymonds
CC=golang-dev
https://golang.org/cl/2700041

src/pkg/container/list/list.go

index 47ceae170c5089ad818d85b4eb6a525107ba0fcb..578864dbe66a157c4f57908873d37a8c1d04817b 100644 (file)
@@ -11,7 +11,7 @@ type Element struct {
        // The front of the list has prev = nil, and the back has next = nil.
        next, prev *Element
 
-       // Thie list to which this element belongs.
+       // The list to which this element belongs.
        list *List
 
        // The contents of this list element.
@@ -40,7 +40,7 @@ func (l *List) Init() *List {
 }
 
 // New returns an initialized list.
-func New() *List { return new(List).Init() }
+func New() *List { return new(List) }
 
 // Front returns the first element in the list.
 func (l *List) Front() *Element { return l.front }
@@ -127,9 +127,6 @@ func (l *List) insertBack(e *Element) {
 
 // PushFront inserts the value at the front of the list and returns a new Element containing the value.
 func (l *List) PushFront(value interface{}) *Element {
-       if l == nil {
-               l.Init()
-       }
        e := &Element{nil, nil, l, value}
        l.insertFront(e)
        return e
@@ -137,9 +134,6 @@ func (l *List) PushFront(value interface{}) *Element {
 
 // PushBack inserts the value at the back of the list and returns a new Element containing the value.
 func (l *List) PushBack(value interface{}) *Element {
-       if l == nil {
-               l.Init()
-       }
        e := &Element{nil, nil, l, value}
        l.insertBack(e)
        return e