From 7935d2e9390962538d017faebbd48fb498ad7447 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Wed, 3 Nov 2010 23:50:43 +0000 Subject: [PATCH] Use append() instead of doing it manually. --- irc/handlers.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 713ee12..cb60055 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -24,17 +24,7 @@ import ( func (conn *Conn) AddHandler(name string, f func(*Conn, *Line)) { n := strings.ToUpper(name) if e, ok := conn.events[n]; ok { - if len(e) == cap(e) { - // crap, we're full. expand e by another 10 handler slots - ne := make([]func(*Conn, *Line), len(e), len(e)+10) - for i := 0; i < len(e); i++ { - ne[i] = e[i] - } - e = ne - } - e = e[0 : len(e)+1] - e[len(e)-1] = f - conn.events[n] = e + conn.events[n] = append(e, f) } else { e := make([]func(*Conn, *Line), 1, 10) e[0] = f