From 0dc19703ab4d3d4dbf91c0d36e744366877520c0 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Sun, 13 Nov 2011 13:32:10 +0000 Subject: [PATCH] gofix weekly fixes for event. --- event/registry.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/event/registry.go b/event/registry.go index 7df894d..7323ecc 100644 --- a/event/registry.go +++ b/event/registry.go @@ -3,8 +3,8 @@ package event import ( "container/list" "strings" - "sync/atomic" "sync" + "sync/atomic" ) type HandlerID uint32 @@ -67,7 +67,8 @@ func (r *registry) AddHandler(h Handler, names ...string) { } r.Lock() defer r.Unlock() -N: for _, name := range names { +N: + for _, name := range names { name = strings.ToLower(name) if _, ok := r.events[name]; !ok { r.events[name] = list.New() @@ -97,7 +98,7 @@ func (r *registry) DelHandler(h Handler, names ...string) { if len(names) == 0 { for name, l := range r.events { if _del(l, h.Id()) { - r.events[name] = nil, false + delete(r.events, name) } } } else { @@ -105,7 +106,7 @@ func (r *registry) DelHandler(h Handler, names ...string) { name = strings.ToLower(name) if l, ok := r.events[name]; ok { if _del(l, h.Id()) { - r.events[name] = nil, false + delete(r.events, name) } } } @@ -122,7 +123,7 @@ func (r *registry) ClearEvents(name string) { defer r.Unlock() if l, ok := r.events[name]; ok { l.Init() // I hope this is enough to GC all list elements. - r.events[name] = nil, false + delete(r.events, name) } }