From 42c5f98096d04805a8a8bf1a2336a70645bb658b Mon Sep 17 00:00:00 2001 From: Alexandre Cesaro Date: Sat, 25 Jul 2015 18:52:52 +0200 Subject: [PATCH] Added a small performance tweak in getRecipients() --- send.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/send.go b/send.go index 82c96d6..6911ec6 100644 --- a/send.go +++ b/send.go @@ -73,7 +73,14 @@ func (m *Message) getFrom() (string, error) { } func (m *Message) getRecipients() ([]string, error) { - var list []string + n := 0 + for _, field := range []string{"To", "Cc", "Bcc"} { + if addresses, ok := m.header[field]; ok { + n += len(addresses) + } + } + list := make([]string, 0, n) + for _, field := range []string{"To", "Cc", "Bcc"} { if addresses, ok := m.header[field]; ok { for _, a := range addresses {