diff options
Diffstat (limited to 'c_lhosts.go')
-rw-r--r-- | c_lhosts.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/c_lhosts.go b/c_lhosts.go index 74726d8..4041279 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -112,6 +112,15 @@ func (lhost *HostList) del(host *HostNode) { } return } + if lhost.last == host { + ptr := lhost.head + for ptr.next != nil { + ptr = ptr.next + } + lhost.last = ptr + lhost.last.next = nil + return + } ptr := lhost.head for ptr.next != nil && ptr.next != host { ptr = ptr.next @@ -122,13 +131,6 @@ func (lhost *HostList) del(host *HostNode) { for ptr := ptr.next; ptr != nil; ptr = ptr.next { ptr.ID -= 1 } - if lhost.last == host { - ptr := lhost.head - for ptr.next != nil { - ptr = ptr.next - } - lhost.last = ptr - } } // return the list node with the according id |