Added a small performance tweak in getRecipients()

This commit is contained in:
Alexandre Cesaro 2015-07-25 18:52:52 +02:00
parent faa9a603a2
commit 42c5f98096
1 changed files with 8 additions and 1 deletions

View File

@ -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 {